#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
double sqrt(int);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int main() {
  int x = 255;
  double rootx = sqrt(x);
  char bang = '!';
  printf("The square root of %d = %f %c%c\n", x, rootx, bang, bang);
  printf("The square root of %05d = %.3f = %10.4f\n", x, rootx, rootx);
  int xx[2] = {3, 5};
  printf("xx: %d, %d\n", xx[0], xx[1]);
  char hello[6] = {'h', 'e', 'l', 'l', 'o', '\0'};
  printf("hello: %s\n", hello);
  printf("%s again\n", "hello");
  char empty_string[1] = {'\0'};
  printf("empty string: [%s]\n", empty_string);
  printf("\n");
  char hello2[6] = "hello";
  char empty_string2[1] = "";
  printf("hello2: %s\n", hello2);
  printf("Another empty string: <%s>\n\n", empty_string2);
  int y;
  printf("Enter an fairly small integer >= 0 (and then return): ");
  scanf("%d", &y);
  printf("We read in %d\n\n", y);
  char buffer[] = "-25.70 junk";
  float h;
  sscanf(buffer, "%d%f", &y, &h);
  printf("Using sscanf %%d%%f, we read in %d and %f from %s\n", y, h, buffer);
  sscanf(buffer, "%f", &h);
  printf("Using sscanf %%f, we read in %f from %s\n\n", h, buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xff,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <sqrt@plt>
movsd  %xmm0,-0x10(%rbp)
movb   $0x21,-0x11(%rbp)
mov    -0x8(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
movsbl -0x11(%rbp),%edx
movsbl -0x11(%rbp),%ecx
lea    0xe72(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xe78(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    0xfb1(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xe81(%rip),%eax
mov    %eax,-0x22(%rbp)
mov    0xe7b(%rip),%ax
mov    %ax,-0x1e(%rbp)
lea    -0x22(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x23(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
lea    -0x23(%rbp),%rsi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xe16(%rip),%eax
mov    %eax,-0x29(%rbp)
mov    0xe10(%rip),%ax
mov    %ax,-0x25(%rbp)
lea    -0x2a(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
lea    -0x29(%rbp),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x2a(%rbp),%rsi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4e(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x30(%rbp),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xe40(%rip),%rax
mov    %rax,-0x3c(%rbp)
mov    0xe3e(%rip),%eax
mov    %eax,-0x34(%rbp)
lea    -0x3c(%rbp),%rdi
lea    0xe34(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x40(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    -0x30(%rbp),%esi
movss  -0x40(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    -0x3c(%rbp),%rdx
lea    0xe13(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    -0x3c(%rbp),%rdi
lea    0xdfe(%rip),%rsi
lea    -0x40(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
movss  -0x40(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    -0x3c(%rbp),%rsi
lea    0xe15(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    $0xff,%edi
call   1070 <sqrt@plt>
movsd  %xmm0,0x28(%rsp)
lea    0xe90(%rip),%rdi
mov    $0xff,%esi
mov    $0x21,%edx
mov    $0x21,%ecx
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
mov    $0xff,%esi
movsd  0x28(%rsp),%xmm0
movaps %xmm0,%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x3,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1040 <printf@plt>
movw   $0x6f,0x24(%rsp)
movl   $0x6c6c6568,0x20(%rsp)
6c
lea    0xeaf(%rip),%rbx
lea    0xe7f(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe77(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movb   $0x0,0xf(%rsp)
lea    0xe6b(%rip),%rdi
lea    0xf(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movw   $0x6f,0x1c(%rsp)
movl   $0x6c6c6568,0x18(%rsp)
6c
movb   $0x0,0xe(%rsp)
lea    0xe54(%rip),%rdi
lea    0x18(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4d(%rip),%rdi
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe80(%rip),%rdi
lea    0x14(%rsp),%r14
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    0x14(%rsp),%esi
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movabs $0x6a2030372e35322d,%rax
30 20 6a
mov    %rax,0x30(%rsp)
movl   $0x6b6e75,0x38(%rsp)
lea    0xe62(%rip),%rsi
lea    0x30(%rsp),%rbx
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
mov    0x14(%rsp),%esi
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe38(%rip),%rdi
mov    %rbx,%rdx
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe24(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3c(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"The square root of %d = %f %c%c\0A\00"
@.str.1 = [41 x i8] c"The square root of %05d = %.3f = %10.4f\0A\00"
@__const.main.xx = [2 x i32] [i32 3, i32 5]
@.str.2 = [12 x i8] c"xx: %d, %d\0A\00"
@__const.main.hello = [6 x i8] c"hello\00"
@.str.3 = [11 x i8] c"hello: %s\0A\00"
@.str.4 = [10 x i8] c"%s again\0A\00"
@.str.5 = [6 x i8] c"hello\00"
@.str.6 = [20 x i8] c"empty string: [%s]\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
@__const.main.hello2 = [6 x i8] c"hello\00"
@.str.8 = [12 x i8] c"hello2: %s\0A\00"
@.str.9 = [29 x i8] c"Another empty string: <%s>\0A\0A\00"
@.str.10 = [55 x i8] c"Enter an fairly small integer >= 0 (and then return): \00"
@.str.11 = [3 x i8] c"%d\00"
@.str.12 = [16 x i8] c"We read in %d\0A\0A\00"
@__const.main.buffer = [12 x i8] c"-25.70 junk\00"
@.str.13 = [5 x i8] c"%d%f\00"
@.str.14 = [51 x i8] c"Using sscanf %%d%%f, we read in %d and %f from %s\0A\00"
@.str.15 = [3 x i8] c"%f\00"
@.str.16 = [42 x i8] c"Using sscanf %%f, we read in %f from %s\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca i8
%5 = alloca [2 x i32]
%6 = alloca [6 x i8]
%7 = alloca [1 x i8]
%8 = alloca [6 x i8]
%9 = alloca [1 x i8]
%10 = alloca i32
%11 = alloca [12 x i8]
%12 = alloca float
store i32 0, i32* %1
store i32 255, i32* %2
%13 = load i32, i32* %2
%14 = call double @sqrt(i32 %13)
store double %14, double* %3
store i8 33, i8* %4
%15 = load i32, i32* %2
%16 = load double, double* %3
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %15, double %16, i32 %18, i32 %20)
%22 = load i32, i32* %2
%23 = load double, double* %3
%24 = load double, double* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %22, double %23, double %24)
%26 = bitcast [2 x i32]* %5 to i8*
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%28 = load i32, i32* %27
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %28, i32 %30)
%32 = bitcast [6 x i8]* %6 to i8*
%33 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%36 = bitcast [1 x i8]* %7 to i8*
%37 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%40 = bitcast [6 x i8]* %8 to i8*
%41 = bitcast [1 x i8]* %9 to i8*
%42 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i8* %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0))
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32* %10)
%48 = load i32, i32* %10
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i32 %48)
%50 = bitcast [12 x i8]* %11 to i8*
%51 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%52 = call i32 (i8*, i8*, ...) @sscanf(i8* %51, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32* %10, float* %12)
%53 = load i32, i32* %10
%54 = load float, float* %12
%55 = fpext float %54 to double
%56 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %53, double %55, i8* %56)
%58 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%59 = call i32 (i8*, i8*, ...) @sscanf(i8* %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), float* %12)
%60 = load float, float* %12
%61 = fpext float %60 to double
%62 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.16, i64 0, i64 0), double %61, i8* %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"The square root of %d = %f %c%c\0A\00"
@.str.1 = [41 x i8] c"The square root of %05d = %.3f = %10.4f\0A\00"
@.str.2 = [12 x i8] c"xx: %d, %d\0A\00"
@.str.3 = [11 x i8] c"hello: %s\0A\00"
@.str.4 = [10 x i8] c"%s again\0A\00"
@.str.6 = [20 x i8] c"empty string: [%s]\0A\00"
@__const.main.hello2 = [6 x i8] c"hello\00"
@.str.8 = [12 x i8] c"hello2: %s\0A\00"
@.str.9 = [29 x i8] c"Another empty string: <%s>\0A\0A\00"
@.str.10 = [55 x i8] c"Enter an fairly small integer >= 0 (and then return): \00"
@.str.11 = [3 x i8] c"%d\00"
@.str.12 = [16 x i8] c"We read in %d\0A\0A\00"
@__const.main.buffer = [12 x i8] c"-25.70 junk\00"
@.str.13 = [5 x i8] c"%d%f\00"
@.str.14 = [51 x i8] c"Using sscanf %%d%%f, we read in %d and %f from %s\0A\00"
@.str.15 = [3 x i8] c"%f\00"
@.str.16 = [42 x i8] c"Using sscanf %%f, we read in %f from %s\0A\0A\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [1 x i8]
%3 = alloca [6 x i8]
%4 = alloca [1 x i8]
%5 = alloca i32
%6 = alloca [12 x i8]
%7 = alloca float
%8 = tail call double @sqrt(i32 255)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 255, double %8, i32 33, i32 33)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 255, double %8, double %8)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 5)
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @__const.main.hello2, i64 0, i64 0))
%15 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
store i8 0, i8* %15
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %15)
%17 = call i32 @putchar(i32 10)
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
store i8 0, i8* %19
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %18)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i8* %19)
%22 = bitcast i32* %5 to i8*
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32* %5)
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%28 = bitcast float* %7 to i8*
%29 = call i32 (i8*, i8*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32* %5, float* %7)
%30 = load i32, i32* %5
%31 = load float, float* %7
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.14, i64 0, i64 0), i32 %30, double %32, i8* %27)
%34 = call i32 (i8*, i8*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), float* %7)
%35 = load float, float* %7
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.16, i64 0, i64 0), double %36, i8* %27)
ret i32 0
}