#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int get_int();
int /*<<< orphan*/ get_string(char *, int);
int /*<<< orphan*/ print_newline();
int /*<<< orphan*/ put_int(int);
int /*<<< orphan*/ put_string(char *);
int main(void) {
  char buffer[1024];
  put_string("Hello, world!\n");
  put_string("Enter a string: ");
  get_string(buffer, 1024);
  put_string("You entered: ");
  put_string(buffer);
  put_string("Enter an integer: ");
  int n = get_int();
  put_string("You entered: ");
  put_int(n);
  print_newline();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1060 <put_string@plt>
lea    0xe9a(%rip),%rdi
call   1060 <put_string@plt>
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   1040 <get_string@plt>
lea    0xe8e(%rip),%rdi
call   1060 <put_string@plt>
lea    -0x410(%rbp),%rdi
call   1060 <put_string@plt>
lea    0xe84(%rip),%rdi
call   1060 <put_string@plt>
mov    $0x0,%al
call   1070 <get_int@plt>
mov    %eax,-0x414(%rbp)
lea    0xe5d(%rip),%rdi
call   1060 <put_string@plt>
mov    -0x414(%rbp),%edi
call   1030 <put_int@plt>
mov    $0x0,%al
call   1050 <print_newline@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
lea    0xe9f(%rip),%rdi
call   1060 <put_string@plt>
lea    0xea2(%rip),%rdi
call   1060 <put_string@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1040 <get_string@plt>
lea    0xe97(%rip),%r14
mov    %r14,%rdi
call   1060 <put_string@plt>
mov    %rbx,%rdi
call   1060 <put_string@plt>
lea    0xe8e(%rip),%rdi
call   1060 <put_string@plt>
xor    %eax,%eax
call   1070 <get_int@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1060 <put_string@plt>
mov    %ebx,%edi
call   1030 <put_int@plt>
xor    %eax,%eax
call   1050 <print_newline@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Hello, world!\0A\00"
@.str.1 = [17 x i8] c"Enter a string: \00"
@.str.2 = [14 x i8] c"You entered: \00"
@.str.3 = [19 x i8] c"Enter an integer: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @put_string(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @put_string(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%7 = call i32 @get_string(i8* %6, i32 1024)
%8 = call i32 @put_string(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%10 = call i32 @put_string(i8* %9)
%11 = call i32 @put_string(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (...) @get_int()
store i32 %12, i32* %3
%13 = call i32 @put_string(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* %3
%15 = call i32 @put_int(i32 %14)
%16 = call i32 (...) @print_newline()
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Hello, world!\0A\00"
@.str.1 = [17 x i8] c"Enter a string: \00"
@.str.2 = [14 x i8] c"You entered: \00"
@.str.3 = [19 x i8] c"Enter an integer: \00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @put_string(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @put_string(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @get_string(i8* %2, i32 1024)
%6 = call i32 @put_string(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @put_string(i8* %2)
%8 = call i32 @put_string(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (...) @get_int()
%10 = call i32 @put_string(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @put_int(i32 %9)
%12 = call i32 (...) @print_newline()
ret i32 0
}