#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printBit(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printf(char *, char *);
int rand_int();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ strcmp(char *, char *);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *fp;
  if ((fp = fopen("testdata.txt", "w")) == NULL) {
    perror("file open error");
    exit(1);
  }
  int a, b, i;
  float fa, fb, fc;
  srand((unsigned)time(NULL));
  printf("%s\n", argv[1]);
  for (i = 0; i < 100000; i++) {
    a = rand_int();
    b = rand_int();
    union {
      int i;
      float f;
    } u;
    u.i = a;
    fa = u.f;
    u.i = b;
    fb = u.f;
    if (strcmp(argv[1], "add") == 0) {
      fc = fa + fb;
    } else if (strcmp(argv[1], "mul") == 0) {
      fc = fa * fb;
    } else if (strcmp(argv[1], "inv") == 0) {
      fc = 1 / fa;
    }
    u.f = fc;
    printBit(fp, a);
    fprintf(fp, " ");
    if (strcmp(argv[1], "inv") != 0) {
      printBit(fp, b);
      fprintf(fp, " ");
    }
    printBit(fp, u.i);
    fprintf(fp, "\n");
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe37(%rip),%rdi
lea    0xe3d(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11fd <main+0x4d>
lea    0xe25(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x186a0,-0x24(%rbp)
jge    1391 <main+0x1e1>
mov    $0x0,%al
call   10a0 <rand_int@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   10a0 <rand_int@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdaf(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    129b <main+0xeb>
movss  -0x28(%rbp),%xmm0
addss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
jmp    1307 <main+0x157>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd81(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12cd <main+0x11d>
movss  -0x28(%rbp),%xmm0
mulss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
jmp    1302 <main+0x152>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd53(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12fd <main+0x14d>
movss  0xd0d(%rip),%xmm0
divss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
jmp    1302 <main+0x152>
jmp    1307 <main+0x157>
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <printBit@plt>
mov    -0x18(%rbp),%rdi
lea    0xd0b(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcf3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1367 <main+0x1b7>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1040 <printBit@plt>
mov    -0x18(%rbp),%rdi
lea    0xcd1(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1040 <printBit@plt>
mov    -0x18(%rbp),%rdi
lea    0xca7(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1228 <main+0x78>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
lea    0xe3c(%rip),%rdi
lea    0xe42(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1324 <main+0x174>
mov    %rax,%rbx
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    0x8(%r14),%rsi
lea    0xe2a(%rip),%rdi
call   1050 <printf@plt>
mov    $0x186a0,%r15d
lea    0xe24(%rip),%r12
jmp    1239 <main+0x89>
nopl   (%rax)
movd   0x10(%rsp),%xmm0
movd   %xmm0,%esi
mov    %rbx,%rdi
call   1040 <printBit@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
add    $0xffffffff,%r15d
je     130b <main+0x15b>
xor    %eax,%eax
call   10a0 <rand_int@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   10a0 <rand_int@plt>
mov    %eax,%ebp
mov    %r13d,0xc(%rsp)
mov    %eax,0x14(%rsp)
mov    0x8(%r14),%rdi
lea    0xdc7(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12a0 <main+0xf0>
mov    0x8(%r14),%rdi
lea    0xdb6(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12b0 <main+0x100>
mov    0x8(%r14),%rdi
mov    %r12,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12c2 <main+0x112>
movss  0xd68(%rip),%xmm0
divss  0xc(%rsp),%xmm0
jmp    12bc <main+0x10c>
movss  0xc(%rsp),%xmm0
addss  0x14(%rsp),%xmm0
jmp    12bc <main+0x10c>
xchg   %ax,%ax
movss  0xc(%rsp),%xmm0
mulss  0x14(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %r13d,%esi
call   1040 <printBit@plt>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    0x8(%r14),%rdi
mov    %r12,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1210 <main+0x60>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <printBit@plt>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
jmp    1210 <main+0x60>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xce8(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%union.anon = type { i32 }
@.str = [13 x i8] c"testdata.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [16 x i8] c"file open error\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [4 x i8] c"add\00"
@.str.5 = [4 x i8] c"mul\00"
@.str.6 = [4 x i8] c"inv\00"
@.str.7 = [2 x i8] c" \00"
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca %union.anon
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = call i64 @time(i32* null)
%21 = trunc i64 %20 to i32
%22 = call i32 @srand(i32 %21)
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %25)
store i32 0, i32* %9
br label %27
27: ; preds = %97, %19
%28 = load i32, i32* %9
%29 = icmp slt i32 %28, 100000
br i1 %29, label %30, label %100
30: ; preds = %27
%31 = call i32 (...) @rand_int()
store i32 %31, i32* %7
%32 = call i32 (...) @rand_int()
store i32 %32, i32* %8
%33 = load i32, i32* %7
%34 = bitcast %union.anon* %13 to i32*
store i32 %33, i32* %34
%35 = bitcast %union.anon* %13 to float*
%36 = load float, float* %35
store float %36, float* %10
%37 = load i32, i32* %8
%38 = bitcast %union.anon* %13 to i32*
store i32 %37, i32* %38
%39 = bitcast %union.anon* %13 to float*
%40 = load float, float* %39
store float %40, float* %11
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %30
%47 = load float, float* %10
%48 = load float, float* %11
%49 = fadd float %47, %48
store float %49, float* %12
br label %71
50: ; preds = %30
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %50
%57 = load float, float* %10
%58 = load float, float* %11
%59 = fmul float %57, %58
store float %59, float* %12
br label %70
60: ; preds = %50
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 1
%63 = load i8*, i8** %62
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %60
%67 = load float, float* %10
%68 = fdiv float 1.000000e+00, %67
store float %68, float* %12
br label %69
69: ; preds = %66, %60
br label %70
70: ; preds = %69, %56
br label %71
71: ; preds = %70, %46
%72 = load float, float* %12
%73 = bitcast %union.anon* %13 to float*
store float %72, float* %73
%74 = load i32*, i32** %6
%75 = load i32, i32* %7
%76 = call i32 @printBit(i32* %74, i32 %75)
%77 = load i32*, i32** %6
%78 = call i32 @fprintf(i32* %77, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 1
%81 = load i8*, i8** %80
%82 = call i64 @strcmp(i8* %81, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %90
84: ; preds = %71
%85 = load i32*, i32** %6
%86 = load i32, i32* %8
%87 = call i32 @printBit(i32* %85, i32 %86)
%88 = load i32*, i32** %6
%89 = call i32 @fprintf(i32* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %90
90: ; preds = %84, %71
%91 = load i32*, i32** %6
%92 = bitcast %union.anon* %13 to i32*
%93 = load i32, i32* %92
%94 = call i32 @printBit(i32* %91, i32 %93)
%95 = load i32*, i32** %6
%96 = call i32 @fprintf(i32* %95, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %97
97: ; preds = %90
%98 = load i32, i32* %9
%99 = add nsw i32 %98, 1
store i32 %99, i32* %9
br label %27
100: ; preds = %27
%101 = load i32*, i32** %6
%102 = call i32 @fclose(i32* %101)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"testdata.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [16 x i8] c"file open error\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [4 x i8] c"add\00"
@.str.5 = [4 x i8] c"mul\00"
@.str.6 = [4 x i8] c"inv\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i64 @time(i32* null)
%10 = trunc i64 %9 to i32
%11 = tail call i32 @srand(i32 %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %8, %50
%16 = phi float [ undef, %8 ], [ %40, %50 ]
%17 = phi i32 [ 0, %8 ], [ %53, %50 ]
%18 = tail call i32 (...) @rand_int()
%19 = tail call i32 (...) @rand_int()
%20 = bitcast i32 %18 to float
%21 = bitcast i32 %19 to float
%22 = load i8*, i8** %12
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %15
%26 = fadd float %20, %21
br label %39
27: ; preds = %15
%28 = load i8*, i8** %12
%29 = tail call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = fmul float %20, %21
br label %39
33: ; preds = %27
%34 = load i8*, i8** %12
%35 = tail call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = fdiv float 1.000000e+00, %20
br label %39
39: ; preds = %31, %37, %33, %25
%40 = phi float [ %26, %25 ], [ %32, %31 ], [ %38, %37 ], [ %16, %33 ]
%41 = bitcast float %40 to i32
%42 = tail call i32 @printBit(i32* %3, i32 %18)
%43 = tail call i32 @fputc(i32 32, i32* %3)
%44 = load i8*, i8** %12
%45 = tail call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %39
%48 = tail call i32 @printBit(i32* %3, i32 %19)
%49 = tail call i32 @fputc(i32 32, i32* %3)
br label %50
50: ; preds = %47, %39
%51 = tail call i32 @printBit(i32* %3, i32 %41)
%52 = tail call i32 @fputc(i32 10, i32* %3)
%53 = add nuw nsw i32 %17, 1
%54 = icmp eq i32 %53, 100000
br i1 %54, label %55, label %15
55: ; preds = %50
%56 = tail call i32 @fclose(i32* %3)
ret i32 0
}