#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 *, ...);
float strtof(char *, int /*<<< orphan*/);
int main_float(int argc, char *argv[]) {
  int i;
  float last = 0.0;
  float x;
  printf("float\n");
  for (i = 1; i < argc; ++i) {
    printf("val str: %s\n", argv[i]);
    x = strtof(argv[i], 0);
    printf("val int"
           ": %d\n",
           (int)(x));
    printf("val flt"
           ": %."
           "9"
           "f\n",
           (double)(x));
    printf("last"
           ": %."
           "3"
           "f\n",
           (double)(last));
    printf("+"
           ": %."
           "3"
           "f\n",
           (double)(last + x));
    printf("-"
           ": %."
           "3"
           "f\n",
           (double)(last - x));
    printf("*"
           ": %."
           "3"
           "f\n",
           (double)(last * x));
    printf("/"
           ": %."
           "3"
           "f\n",
           (double)(last / x));
    printf("\n");
    last = x;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1261 <main_float+0x141>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %esi,%esi
call   1040 <strtof@plt>
movss  %xmm0,-0x1c(%rbp)
cvttss2si -0x1c(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe49(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe36(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
divss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe23(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114c <main_float+0x2c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_float>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xf02(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%ebp
jl     127d <main_float+0x13d>
mov    %ebp,%r13d
xorps  %xmm0,%xmm0
mov    $0x1,%ebp
lea    0xec7(%rip),%r14
lea    0xec9(%rip),%r15
lea    0xecb(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
movss  %xmm0,0x4(%rsp)
mov    (%rbx,%rbp,8),%rsi
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx,%rbp,8),%rdi
xor    %esi,%esi
call   1060 <strtof@plt>
movss  %xmm0,(%rsp)
cvttss2si %xmm0,%esi
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe37(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
addss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe26(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
subss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
mulss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
divss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
movss  (%rsp),%xmm0
cmp    %rbp,%r13
jne    1190 <main_float+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"float\0A\00"
@.str.1 = [13 x i8] c"val str: %s\0A\00"
@.str.2 = [13 x i8] c"val int: %d\0A\00"
@.str.3 = [15 x i8] c"val flt: %.9f\0A\00"
@.str.4 = [12 x i8] c"last: %.3f\0A\00"
@.str.5 = [9 x i8] c"+: %.3f\0A\00"
@.str.6 = [9 x i8] c"-: %.3f\0A\00"
@.str.7 = [9 x i8] c"*: %.3f\0A\00"
@.str.8 = [9 x i8] c"/: %.3f\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main_float(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca float
%7 = alloca float
store i32 %0, i32* %3
store i8** %1, i8*** %4
store float 0.000000e+00, float* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %9
9: ; preds = %57, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %60
13: ; preds = %9
%14 = load i8**, i8*** %4
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i8**, i8*** %4
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call float @strtof(i8* %24, i32 0)
store float %25, float* %7
%26 = load float, float* %7
%27 = fptosi float %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load float, float* %7
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %30)
%32 = load float, float* %6
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %33)
%35 = load float, float* %6
%36 = load float, float* %7
%37 = fadd float %35, %36
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), double %38)
%40 = load float, float* %6
%41 = load float, float* %7
%42 = fsub float %40, %41
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), double %43)
%45 = load float, float* %6
%46 = load float, float* %7
%47 = fmul float %45, %46
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), double %48)
%50 = load float, float* %6
%51 = load float, float* %7
%52 = fdiv float %50, %51
%53 = fpext float %52 to double
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), double %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%56 = load float, float* %7
store float %56, float* %6
br label %57
57: ; preds = %13
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %9
60: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"val str: %s\0A\00"
@.str.2 = [13 x i8] c"val int: %d\0A\00"
@.str.3 = [15 x i8] c"val flt: %.9f\0A\00"
@.str.4 = [12 x i8] c"last: %.3f\0A\00"
@.str.5 = [9 x i8] c"+: %.3f\0A\00"
@.str.6 = [9 x i8] c"-: %.3f\0A\00"
@.str.7 = [9 x i8] c"*: %.3f\0A\00"
@.str.8 = [9 x i8] c"/: %.3f\0A\00"
@str = [6 x i8] c"float\00"
define i32 @main_float(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %36
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 1, %5 ], [ %34, %7 ]
%9 = phi float [ 0.000000e+00, %5 ], [ %14, %7 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %8
%11 = load i8*, i8** %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %10
%14 = tail call float @strtof(i8* %13, i32 0)
%15 = fptosi float %14 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = fpext float %14 to double
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %17)
%19 = fpext float %9 to double
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %19)
%21 = fadd float %9, %14
%22 = fpext float %21 to double
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), double %22)
%24 = fsub float %9, %14
%25 = fpext float %24 to double
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), double %25)
%27 = fmul float %9, %14
%28 = fpext float %27 to double
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), double %28)
%30 = fdiv float %9, %14
%31 = fpext float %30 to double
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), double %31)
%33 = tail call i32 @putchar(i32 10)
%34 = add nuw nsw i64 %8, 1
%35 = icmp eq i64 %34, %6
br i1 %35, label %36, label %7
36: ; preds = %7, %2
ret i32 0
}