#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*/ free(char *);
int getopt(int, char **, char *);
scalar_t__ malloc(int);
char *optarg;
scalar_t__ opterr;
int /*<<< orphan*/ printf(char *, long);
scalar_t__ scanf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ usage(int /*<<< orphan*/);
int main(int argc, char **argv) {
  enum type { FLOAT, LONG } input_type;
  char *in_format;
  in_format = (char *)malloc(256);
  strcpy(in_format, "%d");
  char *out_format;
  out_format = (char *)malloc(256);
  strcpy(out_format, "%d");
  input_type = LONG;
  opterr = 0;
  int c;
  while ((c = getopt(argc, argv, "hlfi:o:")) != -1) {
    switch (c) {
    case 'h':
      usage(stdout);
      return 0;
      break;
    case 'i':
      strcpy(in_format, optarg);
      break;
    case 'l':
      input_type = LONG;
      break;
    case 'f':
      input_type = FLOAT;
      break;
    case 'o':
      strcpy(out_format, optarg);
      break;
    default:
      usage(stderr);
      return 1;
    }
  }
  strcat(out_format, "\n");
  if (input_type == FLOAT) {
    float input;
    while (scanf(in_format, &input) != EOF) {
      printf(out_format, input);
    }
  } else {
    long input;
    while (scanf(in_format, &input) != EOF) {
      printf(out_format, input);
    }
  }
  free(in_format);
  free(out_format);
  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)
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1040 <strcpy@plt>
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1040 <strcpy@plt>
movl   $0x1,-0x14(%rbp)
mov    0x2de8(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe36(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     12b0 <main+0x130>
mov    -0x2c(%rbp),%eax
add    $0xffffff9a,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x9,%eax
ja     1291 <main+0x111>
mov    -0x40(%rbp),%rax
lea    0xdda(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
call   1070 <usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    135b <main+0x1db>
mov    -0x20(%rbp),%rdi
mov    0x2da4(%rip),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
jmp    12ab <main+0x12b>
movl   $0x1,-0x14(%rbp)
jmp    12ab <main+0x12b>
movl   $0x0,-0x14(%rbp)
jmp    12ab <main+0x12b>
mov    -0x28(%rbp),%rdi
mov    0x2d74(%rip),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
jmp    12ab <main+0x12b>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
call   1070 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    135b <main+0x1db>
jmp    11e7 <main+0x67>
mov    -0x28(%rbp),%rdi
lea    0xd78(%rip),%rsi
call   10a0 <strcat@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1307 <main+0x187>
jmp    12cf <main+0x14f>
mov    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    0x2cfb(%rip),%rcx
cmp    (%rcx),%rax
je     1302 <main+0x182>
mov    -0x28(%rbp),%rdi
cvttss2si -0x30(%rbp),%rsi
call   1050 <printf@plt>
jmp    12cf <main+0x14f>
jmp    1342 <main+0x1c2>
jmp    130c <main+0x18c>
mov    -0x20(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    0x2cbe(%rip),%rcx
cmp    (%rcx),%rax
je     133d <main+0x1bd>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <printf@plt>
jmp    130c <main+0x18c>
jmp    1342 <main+0x1c2>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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,%rbx
mov    %edi,%ebp
mov    $0x100,%edi
call   1060 <malloc@plt>
lea    0xe84(%rip),%r12
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    0x2df5(%rip),%rax
movq   $0x0,(%rax)
movl   $0x1,(%rsp)
lea    0xe43(%rip),%r12
lea    0xe11(%rip),%r13
mov    0x2e02(%rip),%r14
jmp    120b <main+0x8b>
nopl   0x0(%rax,%rax,1)
mov    (%r14),%rsi
mov    %r15,%rdi
call   1040 <strcpy@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1090 <getopt@plt>
lea    -0x66(%rax),%ecx
cmp    $0x9,%ecx
ja     124b <main+0xcb>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
mov    (%r14),%rsi
mov    0x8(%rsp),%rdi
call   1040 <strcpy@plt>
jmp    120b <main+0x8b>
movl   $0x0,(%rsp)
jmp    120b <main+0x8b>
movl   $0x1,(%rsp)
jmp    120b <main+0x8b>
cmp    $0xffffffff,%eax
jne    12c1 <main+0x141>
lea    0xddc(%rip),%rsi
mov    %r15,%rbp
mov    %r15,%rdi
call   10a0 <strcat@plt>
cmpl   $0x0,(%rsp)
je     12e6 <main+0x166>
lea    0x10(%rsp),%rsi
mov    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x2d5d(%rip),%r14
cmp    (%r14),%rax
je     1331 <main+0x1b1>
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    (%r14),%rax
jne    12a0 <main+0x120>
jmp    1331 <main+0x1b1>
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
call   1070 <usage@plt>
mov    $0x1,%eax
jmp    1343 <main+0x1c3>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
call   1070 <usage@plt>
jmp    1341 <main+0x1c1>
lea    0x4(%rsp),%rsi
mov    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x2cdf(%rip),%r14
cmp    (%r14),%rax
je     1331 <main+0x1b1>
lea    0x4(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
cvttss2si 0x4(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    (%r14),%rax
jne    1310 <main+0x190>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@opterr = global i64 0
@.str.1 = [8 x i8] c"hlfi:o:\00"
@stdout = global i32 0
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca float
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i64 @malloc(i32 256)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = call i64 @malloc(i32 256)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %8
%18 = load i8*, i8** %8
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
store i64 0, i64* @opterr
br label %20
20: ; preds = %43, %2
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = call i32 @getopt(i32 %21, i8** %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i32 %23, i32* %9
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %44
25: ; preds = %20
%26 = load i32, i32* %9
switch i32 %26, label %40 [
i32 104, label %27
i32 105, label %30
i32 108, label %34
i32 102, label %35
i32 111, label %36
]
27: ; preds = %25
%28 = load i32, i32* @stdout
%29 = call i32 @usage(i32 %28)
store i32 0, i32* %3
br label %77
30: ; preds = %25
%31 = load i8*, i8** %7
%32 = load i8*, i8** @optarg
%33 = call i32 @strcpy(i8* %31, i8* %32)
br label %43
34: ; preds = %25
store i32 1, i32* %6
br label %43
35: ; preds = %25
store i32 0, i32* %6
br label %43
36: ; preds = %25
%37 = load i8*, i8** %8
%38 = load i8*, i8** @optarg
%39 = call i32 @strcpy(i8* %37, i8* %38)
br label %43
40: ; preds = %25
%41 = load i32, i32* @stderr
%42 = call i32 @usage(i32 %41)
store i32 1, i32* %3
br label %77
43: ; preds = %36, %35, %34, %30
br label %20
44: ; preds = %20
%45 = load i8*, i8** %8
%46 = call i32 @strcat(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32, i32* %6
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %61
49: ; preds = %44
br label %50
50: ; preds = %55, %49
%51 = load i8*, i8** %7
%52 = call i64 (i8*, ...) @scanf(i8* %51, float* %10)
%53 = load i64, i64* @EOF
%54 = icmp ne i64 %52, %53
br i1 %54, label %55, label %60
55: ; preds = %50
%56 = load i8*, i8** %8
%57 = load float, float* %10
%58 = fptosi float %57 to i64
%59 = call i32 @printf(i8* %56, i64 %58)
br label %50
60: ; preds = %50
br label %72
61: ; preds = %44
br label %62
62: ; preds = %67, %61
%63 = load i8*, i8** %7
%64 = call i64 (i8*, ...) @scanf(i8* %63, i64* %11)
%65 = load i64, i64* @EOF
%66 = icmp ne i64 %64, %65
br i1 %66, label %67, label %71
67: ; preds = %62
%68 = load i8*, i8** %8
%69 = load i64, i64* %11
%70 = call i32 @printf(i8* %68, i64 %69)
br label %62
71: ; preds = %62
br label %72
72: ; preds = %71, %60
%73 = load i8*, i8** %7
%74 = call i32 @free(i8* %73)
%75 = load i8*, i8** %8
%76 = call i32 @free(i8* %75)
store i32 0, i32* %3
br label %77
77: ; preds = %72, %40, %27
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@opterr = global i64 0
@.str.1 = [8 x i8] c"hlfi:o:\00"
@stdout = global i32 0
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca float
%4 = alloca i64
%5 = tail call i64 @malloc(i32 256)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = tail call i64 @malloc(i32 256)
%9 = inttoptr i64 %8 to i8*
%10 = tail call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* @opterr
br label %11
11: ; preds = %22, %2
%12 = phi i32 [ 1, %2 ], [ %23, %22 ]
br label %13
13: ; preds = %27, %11
%14 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
switch i32 %14, label %28 [
i32 -1, label %31
i32 104, label %15
i32 105, label %18
i32 108, label %22
i32 102, label %21
i32 111, label %24
]
15: ; preds = %13
%16 = load i32, i32* @stdout
%17 = tail call i32 @usage(i32 %16)
br label %62
18: ; preds = %13
%19 = load i8*, i8** @optarg
%20 = tail call i32 @strcpy(i8* %6, i8* %19)
br label %27
21: ; preds = %13
br label %22
22: ; preds = %13, %21
%23 = phi i32 [ 0, %21 ], [ 1, %13 ]
br label %11
24: ; preds = %13
%25 = load i8*, i8** @optarg
%26 = tail call i32 @strcpy(i8* %9, i8* %25)
br label %27
27: ; preds = %24, %18
br label %13
28: ; preds = %13
%29 = load i32, i32* @stderr
%30 = tail call i32 @usage(i32 %29)
br label %62
31: ; preds = %13
%32 = tail call i32 @strcat(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i32 %12, 0
br i1 %33, label %34, label %47
34: ; preds = %31
%35 = bitcast float* %3 to i8*
%36 = call i64 (i8*, ...) @scanf(i8* %6, float* %3)
%37 = load i64, i64* @EOF
%38 = icmp eq i64 %36, %37
br i1 %38, label %46, label %39
39: ; preds = %34, %39
%40 = load float, float* %3
%41 = fptosi float %40 to i64
%42 = call i32 @printf(i8* %9, i64 %41)
%43 = call i64 (i8*, ...) @scanf(i8* %6, float* %3)
%44 = load i64, i64* @EOF
%45 = icmp eq i64 %43, %44
br i1 %45, label %46, label %39
46: ; preds = %39, %34
br label %59
47: ; preds = %31
%48 = bitcast i64* %4 to i8*
%49 = call i64 (i8*, ...) @scanf(i8* %6, i64* %4)
%50 = load i64, i64* @EOF
%51 = icmp eq i64 %49, %50
br i1 %51, label %58, label %52
52: ; preds = %47, %52
%53 = load i64, i64* %4
%54 = call i32 @printf(i8* %9, i64 %53)
%55 = call i64 (i8*, ...) @scanf(i8* %6, i64* %4)
%56 = load i64, i64* @EOF
%57 = icmp eq i64 %55, %56
br i1 %57, label %58, label %52
58: ; preds = %52, %47
br label %59
59: ; preds = %58, %46
%60 = call i32 @free(i8* %6)
%61 = call i32 @free(i8* %9)
br label %62
62: ; preds = %59, %28, %15
%63 = phi i32 [ 1, %28 ], [ 0, %15 ], [ 0, %59 ]
ret i32 %63
}