#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 main() {
  int i;
  int integer, fraction;
  float f = 1.0;
  printf("\n\nLibC Test\n\n");
  printf("compile time: "
         "Mar 15 2022"
         " -- "
         "21:52:22"
         "\n");
  printf("gcc version:  "
         "9.4.0"
         "\n");
  printf("Trying printf with int parameters:\n");
  for (i = 0; i < 4; i++) {
    printf("    [%d] : %d == 0x%02x\n", i, i + 42, i + 42);
  }
  printf("Trying basic float operations:\n");
  for (i = 0; i < 4; i++) {
    integer = (int)f;
    fraction = (int)(f * 100.0) - integer * 100;
    printf("    1.0 + (0.7 * %d) == %d.%d\n", i, integer, fraction);
    f = f + 0.7;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xed9(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11a0 <main+0x90>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
add    $0x2a,%edx
mov    -0x8(%rbp),%ecx
add    $0x2a,%ecx
lea    0xefb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116b <main+0x5b>
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    122c <main+0x11c>
cvttss2si -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe38(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
imul   $0x64,-0xc(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdf7(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b5 <main+0xa5>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf10(%rip),%rdi
call   1030 <puts@plt>
lea    0xf11(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf33(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2a,%edx
mov    $0x2a,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2b,%edx
mov    $0x2b,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2c,%edx
mov    $0x2c,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x2d,%edx
mov    $0x2d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4d(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0x46,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
mov    $0x28,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
mov    $0xa,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\0A\0ALibC Test\0A\0A\00"
@.str.1 = [39 x i8] c"compile time: Mar 15 2022 -- 21:52:22\0A\00"
@.str.2 = [21 x i8] c"gcc version: 9.4.0\0A\00"
@.str.3 = [36 x i8] c"Trying printf with int parameters:\0A\00"
@.str.4 = [25 x i8] c" [%d] : %d == 0x%02x\0A\00"
@.str.5 = [32 x i8] c"Trying basic float operations:\0A\00"
@.str.6 = [31 x i8] c" 1.0 + (0.7 * %d) == %d.%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
store i32 0, i32* %1
store float 1.000000e+00, float* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %10
10: ; preds = %20, %0
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32, i32* %2
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 42
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 42
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %14, i32 %16, i32 %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %10
23: ; preds = %10
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %25
25: ; preds = %46, %23
%26 = load i32, i32* %2
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %49
28: ; preds = %25
%29 = load float, float* %5
%30 = fptosi float %29 to i32
store i32 %30, i32* %3
%31 = load float, float* %5
%32 = fpext float %31 to double
%33 = fmul double %32, 1.000000e+02
%34 = fptosi double %33 to i32
%35 = load i32, i32* %3
%36 = mul nsw i32 %35, 100
%37 = sub nsw i32 %34, %36
store i32 %37, i32* %4
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %38, i32 %39, i32 %40)
%42 = load float, float* %5
%43 = fpext float %42 to double
%44 = fadd double %43, 0x3FE6666666666666
%45 = fptrunc double %44 to float
store float %45, float* %5
br label %46
46: ; preds = %28
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %25
49: ; preds = %25
ret i32 0
}

LLVM IR (-O2):
@.str.4 = [25 x i8] c" [%d] : %d == 0x%02x\0A\00"
@.str.6 = [31 x i8] c" 1.0 + (0.7 * %d) == %d.%d\0A\00"
@str = [13 x i8] c"\0A\0ALibC Test\0A\00"
@str.7 = [38 x i8] c"compile time: Mar 15 2022 -- 21:52:22\00"
@str.8 = [20 x i8] c"gcc version: 9.4.0\00"
@str.9 = [35 x i8] c"Trying printf with int parameters:\00"
@str.10 = [31 x i8] c"Trying basic float operations:\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.7, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.8, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.9, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 42, i32 42)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 43, i32 43)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 2, i32 44, i32 44)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 3, i32 45, i32 45)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.10, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 1, i32 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 1, i32 1, i32 70)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 2, i32 2, i32 40)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 3, i32 3, i32 10)
ret i32 0
}