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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, double, double, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strndup(char *, int);
double strtod(char *, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  char date[720] = "";
  double btc = 0;
  double rate = 0;
  FILE *pFile;
  char line[18];
  if (argc == 3 && strlen(argv[1]) < 720) {
    btc = strtod(argv[1], NULL);
    strcpy(date, argv[2]);
  } else {
    fprintf(stderr, "Bitcoin to US Dollar converter.\n");
    fprintf(stderr, "Usage: %s <#bitcoins> <YYYY-MM-DD>\n", argv[0]);
    fprintf(stderr, "Date range: \"2010-07-17\" to \"2014-01-21\".\n");
    return -1;
  }
  pFile = fopen("/home/superuser/bitcoin.txt", "r");
  if (pFile == NULL)
    perror("Error opening file");
  else {
    while (fgets(line, sizeof(line), pFile) != NULL)
      if (strcmp(strndup(line + 0, 10), date) == 0)
        rate = strtod(strndup(line + 11, sizeof(line) - 11), NULL);
  }
  fclose(pFile);
  printf("%.5f BTC were worth %.5f USD on %s\n", btc, (btc * rate), date);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x310,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x2e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x2d0,%edx
call   1080 <memset@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x2e8(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x2f0(%rbp)
ff
cmpl   $0x3,-0x8(%rbp)
jne    1256 <main+0x96>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
cmp    $0x2d0,%eax
jge    1256 <main+0x96>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtod@plt>
movsd  %xmm0,-0x2e8(%rbp)
ff
lea    -0x2e0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
jmp    12ae <main+0xee>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd9d(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
lea    0xdaa(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a9 <main+0x1e9>
lea    0xdbb(%rip),%rdi
lea    0xdd0(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x2f8(%rbp)
cmpq   $0x0,-0x2f8(%rbp)
jne    12e7 <main+0x127>
lea    0xdb1(%rip),%rdi
call   10e0 <perror@plt>
jmp    136b <main+0x1ab>
jmp    12ec <main+0x12c>
lea    -0x310(%rbp),%rdi
mov    -0x2f8(%rbp),%rdx
mov    $0x12,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     1366 <main+0x1a6>
lea    -0x310(%rbp),%rdi
mov    $0xa,%esi
call   1090 <strndup@plt>
mov    %rax,%rdi
lea    -0x2e0(%rbp),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1361 <main+0x1a1>
lea    -0x310(%rbp),%rdi
add    $0xb,%rdi
mov    $0x7,%esi
call   1090 <strndup@plt>
mov    %rax,%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtod@plt>
movsd  %xmm0,-0x2f0(%rbp)
ff
jmp    12ec <main+0x12c>
jmp    136b <main+0x1ab>
mov    -0x2f8(%rbp),%rdi
call   1050 <fclose@plt>
movsd  -0x2e8(%rbp),%xmm0
ff
movsd  -0x2e8(%rbp),%xmm1
ff
mulsd  -0x2f0(%rbp),%xmm1
ff
lea    -0x2e0(%rbp),%rsi
lea    0xd04(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x310,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x300,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x30(%rsp),%rdi
mov    $0x2d0,%edx
xor    %esi,%esi
call   1080 <memset@plt>
cmp    $0x3,%ebp
jne    12d4 <main+0x114>
mov    0x8(%rbx),%rdi
call   1060 <strlen@plt>
cmp    $0x2cf,%eax
jg     12d4 <main+0x114>
mov    0x8(%rbx),%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x10(%rbx),%rsi
lea    0x30(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xe48(%rip),%rdi
lea    0xe5d(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     1318 <main+0x158>
lea    0x10(%rsp),%rdi
mov    $0x12,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1324 <main+0x164>
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
lea    0x1b(%rsp),%r14
lea    0x10(%rsp),%rbx
lea    0x30(%rsp),%r12
jmp    1299 <main+0xd9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x12,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     132c <main+0x16c>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1090 <strndup@plt>
mov    %rax,%rdi
mov    %r12,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    1280 <main+0xc0>
mov    %r14,%rdi
mov    $0x7,%esi
call   1090 <strndup@plt>
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
movsd  %xmm0,(%rsp)
jmp    1280 <main+0xc0>
mov    0x2d05(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xd1b(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xd28(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xd3b(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    1356 <main+0x196>
lea    0xd6f(%rip),%rdi
call   10e0 <perror@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   1050 <fclose@plt>
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
mulsd  (%rsp),%xmm1
lea    0xd57(%rip),%rdi
lea    0x30(%rsp),%rsi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x300,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Bitcoin to US Dollar converter.\0A\00"
@.str.1 = [36 x i8] c"Usage: %s <#bitcoins> <YYYY-MM-DD>\0A\00"
@.str.2 = [43 x i8] c"Date range: \222010-07-17\22 to \222014-01-21\22.\0A\00"
@.str.3 = [28 x i8] c"/home/superuser/bitcoin.txt\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [19 x i8] c"Error opening file\00"
@.str.6 = [36 x i8] c"%.5f BTC were worth %.5f USD on %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [720 x i8]
%7 = alloca double
%8 = alloca double
%9 = alloca i32*
%10 = alloca [18 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [720 x i8]* %6 to i8*
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 3
br i1 %13, label %14, label %30
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strlen(i8* %17)
%19 = icmp slt i32 %18, 720
br i1 %19, label %20, label %30
20: ; preds = %14
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call double @strtod(i8* %23, i32* null)
store double %24, double* %7
%25 = getelementptr inbounds [720 x i8], [720 x i8]* %6, i64 0, i64 0
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @strcpy(i8* %25, i8* %28)
br label %40
30: ; preds = %14, %2
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %75
40: ; preds = %20
%41 = call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %41, i32** %9
%42 = load i32*, i32** %9
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %66
46: ; preds = %40
br label %47
47: ; preds = %64, %46
%48 = getelementptr inbounds [18 x i8], [18 x i8]* %10, i64 0, i64 0
%49 = load i32*, i32** %9
%50 = call i32* @fgets(i8* %48, i32 18, i32* %49)
%51 = icmp ne i32* %50, null
br i1 %51, label %52, label %65
52: ; preds = %47
%53 = getelementptr inbounds [18 x i8], [18 x i8]* %10, i64 0, i64 0
%54 = getelementptr inbounds i8, i8* %53, i64 0
%55 = call i8* @strndup(i8* %54, i32 10)
%56 = getelementptr inbounds [720 x i8], [720 x i8]* %6, i64 0, i64 0
%57 = call i64 @strcmp(i8* %55, i8* %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %52
%60 = getelementptr inbounds [18 x i8], [18 x i8]* %10, i64 0, i64 0
%61 = getelementptr inbounds i8, i8* %60, i64 11
%62 = call i8* @strndup(i8* %61, i32 7)
%63 = call double @strtod(i8* %62, i32* null)
store double %63, double* %8
br label %64
64: ; preds = %59, %52
br label %47
65: ; preds = %47
br label %66
66: ; preds = %65, %44
%67 = load i32*, i32** %9
%68 = call i32 @fclose(i32* %67)
%69 = load double, double* %7
%70 = load double, double* %7
%71 = load double, double* %8
%72 = fmul double %70, %71
%73 = getelementptr inbounds [720 x i8], [720 x i8]* %6, i64 0, i64 0
%74 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), double %69, double %72, i8* %73)
store i32 0, i32* %3
br label %75
75: ; preds = %66, %30
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Bitcoin to US Dollar converter.\0A\00"
@.str.1 = [36 x i8] c"Usage: %s <#bitcoins> <YYYY-MM-DD>\0A\00"
@.str.2 = [43 x i8] c"Date range: \222010-07-17\22 to \222014-01-21\22.\0A\00"
@.str.3 = [28 x i8] c"/home/superuser/bitcoin.txt\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [19 x i8] c"Error opening file\00"
@.str.6 = [36 x i8] c"%.5f BTC were worth %.5f USD on %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [720 x i8]
%4 = alloca [18 x i8]
%5 = getelementptr inbounds [720 x i8], [720 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 3
br i1 %7, label %8, label %26
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strlen(i8* %10)
%12 = icmp slt i32 %11, 720
br i1 %12, label %13, label %26
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call double @strtod(i8* nocapture %14, i32* null)
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @strcpy(i8* %5, i8* %17)
%19 = call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %34, label %21
21: ; preds = %13
%22 = call i32* @fgets(i8* %6, i32 18, i32* %19)
%23 = icmp eq i32* %22, null
br i1 %23, label %48, label %24
24: ; preds = %21
%25 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 11
br label %36
26: ; preds = %8, %2
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %1
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
br label %53
34: ; preds = %13
%35 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %48
36: ; preds = %24, %44
%37 = phi double [ 0.000000e+00, %24 ], [ %45, %44 ]
%38 = call i8* @strndup(i8* %6, i32 10)
%39 = call i64 @strcmp(i8* %38, i8* %5)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = call i8* @strndup(i8* %25, i32 7)
%43 = call double @strtod(i8* nocapture %42, i32* null)
br label %44
44: ; preds = %41, %36
%45 = phi double [ %43, %41 ], [ %37, %36 ]
%46 = call i32* @fgets(i8* %6, i32 18, i32* %19)
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %36
48: ; preds = %44, %21, %34
%49 = phi double [ 0.000000e+00, %34 ], [ 0.000000e+00, %21 ], [ %45, %44 ]
%50 = call i32 @fclose(i32* %19)
%51 = fmul double %15, %49
%52 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), double %15, double %51, i8* %5)
br label %53
53: ; preds = %48, %26
%54 = phi i32 [ 0, %48 ], [ -1, %26 ]
ret i32 %54
}