#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, float);
scalar_t__ scanf(char *, float *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  char *op = NULL;
  float f, acc = 0;
  if (argc > 2) {
    fprintf(stderr, "Usage: %s [add|sub|mul]\n", *argv);
    return 1;
  } else if (argc == 2) {
    op = *(argv + 1);
  } else {
    op = "add";
  }
  if (strcmp(op, "add") == 0) {
    while (scanf("%f", &f) != EOF)
      acc += f;
  } else if (strcmp(op, "sub") == 0) {
    while (scanf("%f", &f) != EOF)
      acc -= f;
  } else if (strcmp(op, "mul") == 0) {
    acc = 1;
    while (scanf("%f", &f) != EOF)
      acc *= f;
  } else {
    fprintf(stderr, "Invalid operation '%s'.\n", op);
    return 1;
  }
  printf("%f\n", acc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1198 <main+0x58>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe7d(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131e <main+0x1de>
cmpl   $0x2,-0x8(%rbp)
jne    11b3 <main+0x73>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11be <main+0x7e>
lea    0xe63(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11c3 <main+0x83>
mov    -0x18(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    121b <main+0xdb>
jmp    11e2 <main+0xa2>
lea    0xe38(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
mov    0x2def(%rip),%rcx
cmp    (%rcx),%rax
je     1216 <main+0xd6>
movss  -0x1c(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    11e2 <main+0xa2>
jmp    1306 <main+0x1c6>
mov    -0x18(%rbp),%rdi
lea    0xdfe(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1277 <main+0x137>
jmp    123a <main+0xfa>
lea    0xde0(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
mov    0x2d97(%rip),%rcx
cmp    (%rcx),%rax
je     1272 <main+0x132>
movss  -0x1c(%rbp),%xmm1
movss  -0x20(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    123a <main+0xfa>
jmp    1301 <main+0x1c1>
mov    -0x18(%rbp),%rdi
lea    0xda6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12d7 <main+0x197>
movss  0xd67(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
lea    0xd7c(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
mov    0x2d33(%rip),%rcx
cmp    (%rcx),%rax
je     12d2 <main+0x192>
movss  -0x1c(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    129e <main+0x15e>
jmp    12fc <main+0x1bc>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd41(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131e <main+0x1de>
jmp    1301 <main+0x1c1>
jmp    1306 <main+0x1c6>
movss  -0x20(%rbp),%xmm0
lea    0xd33(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x3,%edi
jl     1170 <main+0x30>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xea3(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    1300 <main+0x1c0>
cmp    $0x2,%edi
jne    117b <main+0x3b>
mov    0x8(%rsi),%rbx
jmp    1182 <main+0x42>
lea    0xe9b(%rip),%rbx
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11db <main+0x9b>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1237 <main+0xf7>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1294 <main+0x154>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
mov    %rbx,%rdx
jmp    1161 <main+0x21>
lea    0xe3f(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2df5(%rip),%r15
xorps  %xmm0,%xmm0
cmp    (%r15),%rax
je     12f2 <main+0x1b2>
xorps  %xmm0,%xmm0
lea    0xe18(%rip),%r14
lea    0x8(%rsp),%rbx
xchg   %ax,%ax
addss  0x8(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
cmp    (%r15),%rax
jne    1210 <main+0xd0>
jmp    12f2 <main+0x1b2>
lea    0xde3(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2d99(%rip),%r15
xorps  %xmm0,%xmm0
cmp    (%r15),%rax
je     12f2 <main+0x1b2>
xorps  %xmm0,%xmm0
lea    0xdbc(%rip),%r14
lea    0x8(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
subss  0x8(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
cmp    (%r15),%rax
jne    1270 <main+0x130>
jmp    12f2 <main+0x1b2>
lea    0xd86(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2d3c(%rip),%r15
cmp    (%r15),%rax
jne    12bb <main+0x17b>
movss  0xd47(%rip),%xmm0
jmp    12f2 <main+0x1b2>
movss  0xd3d(%rip),%xmm0
lea    0xd57(%rip),%r14
lea    0x8(%rsp),%rbx
nop
mulss  0x8(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
cmp    (%r15),%rax
jne    12d0 <main+0x190>
lea    0xd4c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s [add|sub|mul]\0A\00"
@.str.1 = [4 x i8] c"add\00"
@.str.2 = [3 x i8] c"%f\00"
@EOF = global i64 0
@.str.3 = [4 x i8] c"sub\00"
@.str.4 = [4 x i8] c"mul\00"
@.str.5 = [25 x i8] c"Invalid operation '%s'.\0A\00"
@.str.6 = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca float
%8 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store float 0.000000e+00, float* %8
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %76
16: ; preds = %2
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %6
br label %24
23: ; preds = %16
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %24
24: ; preds = %23, %19
br label %25
25: ; preds = %24
%26 = load i8*, i8** %6
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %25
br label %30
30: ; preds = %34, %29
%31 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %7)
%32 = load i64, i64* @EOF
%33 = icmp ne i64 %31, %32
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load float, float* %7
%36 = load float, float* %8
%37 = fadd float %36, %35
store float %37, float* %8
br label %30
38: ; preds = %30
br label %73
39: ; preds = %25
%40 = load i8*, i8** %6
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %53
43: ; preds = %39
br label %44
44: ; preds = %48, %43
%45 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %7)
%46 = load i64, i64* @EOF
%47 = icmp ne i64 %45, %46
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = load float, float* %7
%50 = load float, float* %8
%51 = fsub float %50, %49
store float %51, float* %8
br label %44
52: ; preds = %44
br label %72
53: ; preds = %39
%54 = load i8*, i8** %6
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %67
57: ; preds = %53
store float 1.000000e+00, float* %8
br label %58
58: ; preds = %62, %57
%59 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %7)
%60 = load i64, i64* @EOF
%61 = icmp ne i64 %59, %60
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = load float, float* %7
%64 = load float, float* %8
%65 = fmul float %64, %63
store float %65, float* %8
br label %58
66: ; preds = %58
br label %71
67: ; preds = %53
%68 = load i32, i32* @stderr
%69 = load i8*, i8** %6
%70 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %69)
store i32 1, i32* %3
br label %76
71: ; preds = %66
br label %72
72: ; preds = %71, %52
br label %73
73: ; preds = %72, %38
%74 = load float, float* %8
%75 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), float %74)
store i32 0, i32* %3
br label %76
76: ; preds = %73, %67, %11
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s [add|sub|mul]\0A\00"
@.str.1 = [4 x i8] c"add\00"
@.str.2 = [3 x i8] c"%f\00"
@EOF = global i64 0
@.str.3 = [4 x i8] c"sub\00"
@.str.4 = [4 x i8] c"mul\00"
@.str.5 = [25 x i8] c"Invalid operation '%s'.\0A\00"
@.str.6 = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca float
%4 = bitcast float* %3 to i8*
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %64
10: ; preds = %2
%11 = icmp eq i32 %0, 2
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
br label %15
15: ; preds = %10, %12
%16 = phi i8* [ %14, %12 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %10 ]
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %15
%20 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%21 = load i64, i64* @EOF
%22 = icmp eq i64 %20, %21
br i1 %22, label %61, label %23
23: ; preds = %19, %23
%24 = phi float [ %26, %23 ], [ 0.000000e+00, %19 ]
%25 = load float, float* %3
%26 = fadd float %24, %25
%27 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%28 = load i64, i64* @EOF
%29 = icmp eq i64 %27, %28
br i1 %29, label %61, label %23
30: ; preds = %15
%31 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %44
33: ; preds = %30
%34 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%35 = load i64, i64* @EOF
%36 = icmp eq i64 %34, %35
br i1 %36, label %61, label %37
37: ; preds = %33, %37
%38 = phi float [ %40, %37 ], [ 0.000000e+00, %33 ]
%39 = load float, float* %3
%40 = fsub float %38, %39
%41 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%42 = load i64, i64* @EOF
%43 = icmp eq i64 %41, %42
br i1 %43, label %61, label %37
44: ; preds = %30
%45 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %58
47: ; preds = %44
%48 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%49 = load i64, i64* @EOF
%50 = icmp eq i64 %48, %49
br i1 %50, label %61, label %51
51: ; preds = %47, %51
%52 = phi float [ %54, %51 ], [ 1.000000e+00, %47 ]
%53 = load float, float* %3
%54 = fmul float %52, %53
%55 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%56 = load i64, i64* @EOF
%57 = icmp eq i64 %55, %56
br i1 %57, label %61, label %51
58: ; preds = %44
%59 = load i32, i32* @stderr
%60 = tail call i32 @fprintf(i32 %59, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %16)
br label %64
61: ; preds = %51, %37, %23, %47, %33, %19
%62 = phi float [ 0.000000e+00, %19 ], [ 0.000000e+00, %33 ], [ 1.000000e+00, %47 ], [ %26, %23 ], [ %40, %37 ], [ %54, %51 ]
%63 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), float %62)
br label %64
64: ; preds = %61, %58, %6
%65 = phi i32 [ 1, %6 ], [ 0, %61 ], [ 1, %58 ]
ret i32 %65
}