Question

In: Computer Science

Write equivalent LLVM IR for the following SimpleC program. I need the answer ASAP please if...

Write equivalent LLVM IR for the following SimpleC program. I need the answer ASAP please if possible

int x;
int y;
read x;
y = x + 1;
print y;

Solutions

Expert Solution

The program below is the LLVM IR program for the given C program:

; ModuleID = 'testfile.c'
source_filename = "testfile.c"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-darwin18.7.0"

@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1

; Function Attrs: noinline nounwind optnone
define i32 @main() #0 {
entry:
%x = alloca i32, align 4
%y = alloca i32, align 4
%call = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i32* %x)
%0 = load i32, i32* %x, align 4
%add = add nsw i32 %0, 1
store i32 %add, i32* %y, align 4
%1 = load i32, i32* %y, align 4
%call1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i32 %1)
ret i32 0
}

declare i32 @scanf(i8*, ...) #1

declare i32 @printf(i8*, ...) #1

attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"Apple clang version 11.0.0 (clang-1100.0.33.8)"}

C program:

LLVR program:


Related Solutions

I need this written in C # ASAP Write a C# console program that continually asks...
I need this written in C # ASAP Write a C# console program that continually asks the user "Do you want to enter a name (Y/N)? ". Use a "while" loop to accomplish this. As long as the user enters either an upper or lowercase 'Y', then prompt to the screen "Enter First and Last Name: " and then get keyboard input of the name. After entering the name, display the name to the screen.
. NEED ANSWER ASAP / ANSWER NEVER USED BEFORE, COMPLETELY NEW ANSWER PLEASE Write a Strategic...
. NEED ANSWER ASAP / ANSWER NEVER USED BEFORE, COMPLETELY NEW ANSWER PLEASE Write a Strategic Marketing Plan on the Nike brand ,Write in depth detail on the following: Marketing Plan, Draft Environmental Issues Action Programs Budget and Breakeven-Point (BEP) ANSWER THROUGHLY 1-2 pages *** IN PARAGRAPGH FORM PLEASE NOT BULLET POINTS COPY AND PASTE Answer in paragraphs, and no picture attachment please. NEEDS TO BE AN ORIGINAL SOURCE ANSWER NEVER USED BEFORE
Please answer this question ASAP an explain in detail. I really need it before the night...
Please answer this question ASAP an explain in detail. I really need it before the night is over. a) Explain what a catalytic process is and how it is different from the non-catalytic version of the process. Give an example of an enzymatic process other than amylase and describe the substrate(s)/product(s): b) Describe what the enzyme amylase does and what would happen in the absence of this enzyme:
i need a conclusion for my paper on ADHD. I need this asap please have to...
i need a conclusion for my paper on ADHD. I need this asap please have to turn my paper in one hour!!!! thank you            In the recent times, ADHD is being seen in the light of cerebral dysfunction with too much focus on clinical treatment using medication at the same time keeping psychotherapy at bay which shows a dangerous trend. Psychotherapy even though cannot explain the cause of the condition, but it can help the children in coping his...
(please i need the answer asap )Computer chips defects are classified according to type of defect...
(please i need the answer asap )Computer chips defects are classified according to type of defect and shift on which it was made. The numbers of defects are recorded in the the table below. Do the data present sufficient evidence to indicate that the type of computer chip defect varies with the shift during which they are produced? Test at the 5% level of significance. Shift Type 1 2 3 TOTAL A 14 25 32 71 B 20 30 16...
. NEED NEW ANSWER ASAP / ANSWER NEVER USED BEFORE NEED NEW ANSWER ASAP / ANSWER...
. NEED NEW ANSWER ASAP / ANSWER NEVER USED BEFORE NEED NEW ANSWER ASAP / ANSWER NEVER USED BEFORE Explain horizontal and vertical analysis. Do some research .explain why these methods are used. What can we learn from horizontal and vertical analysis statements? How can results vary compared to other corporations and why can ratios better than using dollars? ANSWER THROUGHLY 1 page *** IN PARAGRAPGH FORM PLEASE NOT BULLET POINTS COPY AND PASTE Answer in paragraphs, and no picture...
please answer all parts of the question! i also need to find the equivalent effective annual...
please answer all parts of the question! i also need to find the equivalent effective annual interest rate for this $10, 000 investment over this 10 year period. You purchase a 10 year annuity with payments at the end of each year for $10,000 (where for this annuity effective annual interest is 4%). Immediately after you receive payments, you deposit the payment into an account earning 5% effective annual interest. How much is in this account at the end of...
. NEED ANSWER ASAP / ANSWER NEVER USED BEFORE, COMPLETELY NEW ANSWER PLEASE Is it always...
. NEED ANSWER ASAP / ANSWER NEVER USED BEFORE, COMPLETELY NEW ANSWER PLEASE Is it always necessary for government to intervene and internalize the profit and the cost externalities? Illustrate your answer using a real world example. ANSWER THROUGHLY 1-2 pages *** IN PARAGRAPGH FORM PLEASE NOT BULLET POINTS COPY AND PASTE Answer in paragraphs, and no picture attachment please. NEEDS TO BE AN ORIGINAL SOURCE ANSWER NEVER USED BEFORE
. NEED ANSWER ASAP / ANSWER NEVER USED BEFORE, COMPLETELY NEW ANSWER PLEASE There are four...
. NEED ANSWER ASAP / ANSWER NEVER USED BEFORE, COMPLETELY NEW ANSWER PLEASE There are four market models: perfect competition, monopolistic competition, oligopoly and monopoly. Briefly discuss the assumptions of each of these four models and give examples of each. Explain the long run economic profit earned by each of the four. Explain how the concept of economic profit might help explain the rationale for the government’s granting of monopolies to those firms that protect their product with a patent....
. NEED ANSWER ASAP / ANSWER NEVER USED BEFORE, COMPLETELY NEW ANSWER PLEASE What is a...
. NEED ANSWER ASAP / ANSWER NEVER USED BEFORE, COMPLETELY NEW ANSWER PLEASE What is a market niche? Discuss the strategies and risks associated with this competitive position. Give an example in your answer. ANSWER THROUGHLY 1-2 pages *** IN PARAGRAPGH FORM PLEASE NOT BULLET POINTS COPY AND PASTE Answer in paragraphs, and no picture attachment please. NEEDS TO BE AN ORIGINAL SOURCE ANSWER NEVER USED BEFORE
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT