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

/* Variables and functions */
int /*<<< orphan*/ calculateChange(unsigned int *, unsigned int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, unsigned int *);
int getSizeOfDenominations(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *, unsigned int *, unsigned int *,
                         unsigned int *);
int main(void) {
  FILE *myFiles;
  myFiles = fopen("denominations.txt", "r");
  if (myFiles == NULL) {
    printf("./denominations.txt either does not exist or can't be opened.\n");
    return 1;
  }
  if (getSizeOfDenominations(myFiles) == 0) {
    printf("./denominations.txt was empty.\n");
    return 2;
  }
  unsigned int denominations[getSizeOfDenominations(myFiles)];
  for (size_t i = 0; i < sizeof(denominations) / sizeof(*denominations); ++i) {
    fscanf(myFiles, "%u", &denominations[i]);
  }
  fclose(myFiles);
  unsigned int tender[2] = {0, 0};
  unsigned int bill[2] = {0, 0};
  scanf("%u.%u %u.%u", &tender[0], &tender[1], &bill[0], &bill[1]);
  unsigned int change =
      (((tender[0] * 100) + tender[1]) - ((bill[0] * 100) + bill[1]));
  for (size_t i = 0; i < sizeof(denominations) / sizeof(*denominations); ++i) {
    calculateChange(&change, denominations[i]);
  }
  if (change > 0) {
    printf("The change wasn't completely divisible by the denominations set.\n"
           "Your total change left over is $%u.%02u\n",
           change / 100, change % 100);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
lea    0xe75(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11cb <main+0x4b>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1361 <main+0x1e1>
mov    -0x10(%rbp),%rdi
call   10a0 <getSizeOfDenominations@plt>
cmp    $0x0,%eax
jne    11f7 <main+0x77>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1361 <main+0x1e1>
mov    -0x10(%rbp),%rdi
call   10a0 <getSizeOfDenominations@plt>
mov    %eax,%eax
mov    %rax,-0x58(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x58(%rbp),%rcx
mov    -0x28(%rbp),%rax
shl    $0x2,%rcx
shr    $0x2,%rcx
cmp    %rcx,%rax
jae    127b <main+0xfb>
mov    -0x50(%rbp),%rdx
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe17(%rip),%rsi
call   1070 <fscanf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1232 <main+0xb2>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
lea    -0x30(%rbp),%rsi
lea    -0x30(%rbp),%rdx
add    $0x4,%rdx
lea    -0x38(%rbp),%rcx
lea    -0x38(%rbp),%r8
add    $0x4,%r8
lea    0xdb0(%rip),%rdi
call   1080 <scanf@plt>
imul   $0x64,-0x30(%rbp),%eax
add    -0x2c(%rbp),%eax
imul   $0x64,-0x38(%rbp),%ecx
add    -0x34(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x3c(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x58(%rbp),%rcx
mov    -0x48(%rbp),%rax
shl    $0x2,%rcx
shr    $0x2,%rcx
cmp    %rcx,%rax
jae    1321 <main+0x1a1>
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    -0x3c(%rbp),%rdi
call   1030 <calculateChange@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    12e3 <main+0x163>
cmpl   $0x0,-0x3c(%rbp)
jbe    1353 <main+0x1d3>
mov    -0x3c(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%esi
mov    -0x3c(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe68(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12b4 <main+0x134>
mov    %rax,%r15
mov    %rax,%rdi
call   10a0 <getSizeOfDenominations@plt>
test   %eax,%eax
je     12c7 <main+0x147>
mov    %r15,%rdi
call   10a0 <getSizeOfDenominations@plt>
mov    %rsp,-0x50(%rbp)
mov    %eax,%ecx
mov    %rsp,%r12
mov    %rcx,-0x48(%rbp)
lea    0xf(,%rcx,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r12
mov    %r12,%rsp
test   %eax,%eax
je     1218 <main+0x98>
lea    0xe2b(%rip),%r14
mov    %r12,%rbx
mov    -0x48(%rbp),%r13
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%r13
jne    1200 <main+0x80>
mov    %r15,%rdi
call   1050 <fclose@plt>
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x3c(%rbp),%rdx
lea    -0x34(%rbp),%r8
lea    0xdd5(%rip),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x38(%rbp),%rcx
call   1080 <scanf@plt>
mov    -0x40(%rbp),%eax
mov    -0x3c(%rbp),%edx
sub    -0x38(%rbp),%eax
sub    -0x34(%rbp),%edx
imul   $0x64,%eax,%eax
add    %eax,%edx
mov    %edx,-0x2c(%rbp)
mov    -0x48(%rbp),%r15
test   %r15,%r15
je     1288 <main+0x108>
xor    %ebx,%ebx
lea    -0x2c(%rbp),%r14
nop
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
call   1040 <calculateChange@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1270 <main+0xf0>
mov    -0x2c(%rbp),%edx
test   %edx,%edx
je     12ac <main+0x12c>
mov    %edx,%eax
imul   $0x51eb851f,%rax,%rsi
shr    $0x25,%rsi
imul   $0x64,%esi,%eax
sub    %eax,%edx
lea    0xd7b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
mov    -0x50(%rbp),%rsp
jmp    12d8 <main+0x158>
lea    0xdee(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    12d8 <main+0x158>
lea    0xdbc(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"denominations.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [63 x i8] c"./denominations.txt either does not exist or can't be opened.\0A\00"
@.str.3 = [32 x i8] c"./denominations.txt was empty.\0A\00"
@.str.4 = [3 x i8] c"%u\00"
@.str.5 = [12 x i8] c"%u.%u %u.%u\00"
@.str.6 = [106 x i8] c"The change wasn't completely divisible by the denominations set.\0AYour total change left over is $%u.%02u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
%8 = alloca i32
%9 = alloca i64
store i32 0, i32* %1
%10 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
%11 = load i32*, i32** %2
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %87
15: ; preds = %0
%16 = load i32*, i32** %2
%17 = call i32 @getSizeOfDenominations(i32* %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %1
br label %87
21: ; preds = %15
%22 = load i32*, i32** %2
%23 = call i32 @getSizeOfDenominations(i32* %22)
%24 = zext i32 %23 to i64
%25 = call i8* @llvm.stacksave()
store i8* %25, i8** %3
%26 = alloca i32, i64 %24
store i64 %24, i64* %4
store i64 0, i64* %5
br label %27
27: ; preds = %37, %21
%28 = load i64, i64* %5
%29 = mul nuw i64 4, %24
%30 = udiv i64 %29, 4
%31 = icmp ult i64 %28, %30
br i1 %31, label %32, label %40
32: ; preds = %27
%33 = load i32*, i32** %2
%34 = load i64, i64* %5
%35 = getelementptr inbounds i32, i32* %26, i64 %34
%36 = call i32 @fscanf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %35)
br label %37
37: ; preds = %32
%38 = load i64, i64* %5
%39 = add i64 %38, 1
store i64 %39, i64* %5
br label %27
40: ; preds = %27
%41 = load i32*, i32** %2
%42 = call i32 @fclose(i32* %41)
%43 = bitcast [2 x i32]* %6 to i8*
%44 = bitcast [2 x i32]* %7 to i8*
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%46 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%49 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32* %45, i32* %46, i32* %47, i32* %48)
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%51 = load i32, i32* %50
%52 = mul i32 %51, 100
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%54 = load i32, i32* %53
%55 = add i32 %52, %54
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%57 = load i32, i32* %56
%58 = mul i32 %57, 100
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%60 = load i32, i32* %59
%61 = add i32 %58, %60
%62 = sub i32 %55, %61
store i32 %62, i32* %8
store i64 0, i64* %9
br label %63
63: ; preds = %73, %40
%64 = load i64, i64* %9
%65 = mul nuw i64 4, %24
%66 = udiv i64 %65, 4
%67 = icmp ult i64 %64, %66
br i1 %67, label %68, label %76
68: ; preds = %63
%69 = load i64, i64* %9
%70 = getelementptr inbounds i32, i32* %26, i64 %69
%71 = load i32, i32* %70
%72 = call i32 @calculateChange(i32* %8, i32 %71)
br label %73
73: ; preds = %68
%74 = load i64, i64* %9
%75 = add i64 %74, 1
store i64 %75, i64* %9
br label %63
76: ; preds = %63
%77 = load i32, i32* %8
%78 = icmp ugt i32 %77, 0
br i1 %78, label %79, label %85
79: ; preds = %76
%80 = load i32, i32* %8
%81 = udiv i32 %80, 100
%82 = load i32, i32* %8
%83 = urem i32 %82, 100
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.6, i64 0, i64 0), i32 %81, i32 %83)
br label %85
85: ; preds = %79, %76
store i32 0, i32* %1
%86 = load i8*, i8** %3
br label %87
87: ; preds = %85, %19, %13
%88 = load i32, i32* %1
ret i32 %88
}

LLVM IR (-O2):
@.str = [18 x i8] c"denominations.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.4 = [3 x i8] c"%u\00"
@.str.5 = [12 x i8] c"%u.%u %u.%u\00"
@.str.6 = [106 x i8] c"The change wasn't completely divisible by the denominations set.\0AYour total change left over is $%u.%02u\0A\00"
@str = [31 x i8] c"./denominations.txt was empty.\00"
@str.7 = [62 x i8] c"./denominations.txt either does not exist or can't be opened.\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to [2 x i32]*
%3 = alloca i64
%4 = bitcast i64* %3 to [2 x i32]*
%5 = alloca i32
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.7, i64 0, i64 0))
br label %62
10: ; preds = %0
%11 = tail call i32 @getSizeOfDenominations(i32* %6)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %62
15: ; preds = %10
%16 = tail call i32 @getSizeOfDenominations(i32* %6)
%17 = zext i32 %16 to i64
%18 = tail call i8* @llvm.stacksave()
%19 = alloca i32, i64 %17
%20 = icmp eq i32 %16, 0
br i1 %20, label %21, label %39
21: ; preds = %39, %15
%22 = call i32 @fclose(i32* %6)
%23 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%24 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%25 = bitcast i64* %1 to i32*
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%27 = bitcast i64* %3 to i32*
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%29 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32* %25, i32* %26, i32* %27, i32* %28)
%30 = bitcast i32* %5 to i8*
%31 = load i32, i32* %25
%32 = load i32, i32* %26
%33 = load i32, i32* %27
%34 = load i32, i32* %28
%35 = sub i32 %31, %33
%36 = mul i32 %35, 100
%37 = sub i32 %32, %34
%38 = add i32 %37, %36
store i32 %38, i32* %5
br i1 %20, label %47, label %50
39: ; preds = %15, %39
%40 = phi i64 [ %43, %39 ], [ 0, %15 ]
%41 = getelementptr inbounds i32, i32* %19, i64 %40
%42 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %41)
%43 = add nuw nsw i64 %40, 1
%44 = icmp eq i64 %43, %17
br i1 %44, label %21, label %39
45: ; preds = %50
%46 = load i32, i32* %5
br label %47
47: ; preds = %45, %21
%48 = phi i32 [ %46, %45 ], [ %38, %21 ]
%49 = icmp eq i32 %48, 0
br i1 %49, label %61, label %57
50: ; preds = %21, %50
%51 = phi i64 [ %55, %50 ], [ 0, %21 ]
%52 = getelementptr inbounds i32, i32* %19, i64 %51
%53 = load i32, i32* %52
%54 = call i32 @calculateChange(i32* %5, i32 %53)
%55 = add nuw nsw i64 %51, 1
%56 = icmp eq i64 %55, %17
br i1 %56, label %45, label %50
57: ; preds = %47
%58 = udiv i32 %48, 100
%59 = urem i32 %48, 100
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([106 x i8], [106 x i8]* @.str.6, i64 0, i64 0), i32 %58, i32 %59)
br label %61
61: ; preds = %57, %47
br label %62
62: ; preds = %61, %13, %8
%63 = phi i32 [ 1, %8 ], [ 2, %13 ], [ 0, %61 ]
ret i32 %63
}