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


x86 assembly (clang, -O0):
<main_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1249 <main_double+0x129>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
movsd  %xmm0,-0x28(%rbp)
cvttsd2si -0x28(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xe79(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
lea    0xe69(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
lea    0xe5a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
lea    0xe4b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114c <main_double+0x2c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeff(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%ebp
jl     126c <main_double+0x12c>
mov    %ebp,%r13d
xorpd  %xmm0,%xmm0
mov    $0x1,%ebp
lea    0xec3(%rip),%r14
lea    0xec5(%rip),%r15
lea    0xec7(%rip),%r12
nopl   0x0(%rax)
movsd  %xmm0,0x10(%rsp)
mov    (%rbx,%rbp,8),%rsi
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rbx,%rbp,8),%rdi
xor    %esi,%esi
call   1050 <strtod@plt>
movsd  %xmm0,0x8(%rsp)
cvttsd2si %xmm0,%esi
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe48(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xe43(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
lea    0xe2f(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
movsd  0x8(%rsp),%xmm0
cmp    %rbp,%r13
jne    1190 <main_double+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"double\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: %.9f\0A\00"
@.str.5 = [9 x i8] c"+: %.9f\0A\00"
@.str.6 = [9 x i8] c"-: %.9f\0A\00"
@.str.7 = [9 x i8] c"*: %.9f\0A\00"
@.str.8 = [9 x i8] c"/: %.9f\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main_double(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %3
store i8** %1, i8*** %4
store double 0.000000e+00, double* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %9
9: ; preds = %51, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %54
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 double @strtod(i8* %24, i32 0)
store double %25, double* %7
%26 = load double, double* %7
%27 = fptosi double %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 double, double* %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %29)
%31 = load double, double* %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %31)
%33 = load double, double* %6
%34 = load double, double* %7
%35 = fadd double %33, %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), double %35)
%37 = load double, double* %6
%38 = load double, double* %7
%39 = fsub double %37, %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), double %39)
%41 = load double, double* %6
%42 = load double, double* %7
%43 = fmul double %41, %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), double %43)
%45 = load double, double* %6
%46 = load double, double* %7
%47 = fdiv double %45, %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), double %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%50 = load double, double* %7
store double %50, double* %6
br label %51
51: ; preds = %13
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
br label %9
54: ; 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: %.9f\0A\00"
@.str.5 = [9 x i8] c"+: %.9f\0A\00"
@.str.6 = [9 x i8] c"-: %.9f\0A\00"
@.str.7 = [9 x i8] c"*: %.9f\0A\00"
@.str.8 = [9 x i8] c"/: %.9f\0A\00"
@str = [7 x i8] c"double\00"
define i32 @main_double(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %30
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 1, %5 ], [ %28, %7 ]
%9 = phi double [ 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 double @strtod(i8* %13, i32 0)
%15 = fptosi double %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 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %14)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %9)
%19 = fadd double %9, %14
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), double %19)
%21 = fsub double %9, %14
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), double %21)
%23 = fmul double %9, %14
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), double %23)
%25 = fdiv double %9, %14
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), double %25)
%27 = tail call i32 @putchar(i32 10)
%28 = add nuw nsw i64 %8, 1
%29 = icmp eq i64 %28, %6
br i1 %29, label %30, label %7
30: ; preds = %7, %2
ret i32 0
}