#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 */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  printf("Enter Number of Denominations \n");
  int n, i;
  scanf("%d", &n);
  int denominations[n], frequency[n];
  for (i = 0; i < n; i++)
    frequency[i] = 0;
  printf("Enter Denominations in descending order \n");
  for (i = 0; i < n; i++)
    scanf("%d", &denominations[i]);
  printf("Enter Bill \n");
  int bill;
  scanf("%d", &bill);
  i = 0;
  while (bill > 0 && i < n) {
    frequency[i] = bill / denominations[i];
    bill = bill - (frequency[i] * denominations[i]);
    i++;
  }
  if (bill == 0)
    for (i = 0; i < n; i++)
      printf("%d * %d \n", denominations[i], frequency[i]);
  else
    printf("Bill cannot be paid \n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c4 <main+0xa4>
mov    -0x38(%rbp),%rax
movslq -0xc(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119b <main+0x7b>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120e <main+0xee>
mov    -0x40(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe25(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d9 <main+0xb9>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdfd(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x41(%rbp)
jle    124e <main+0x12e>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
setl   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    125e <main+0x13e>
jmp    12a3 <main+0x183>
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rcx
mov    -0x2c(%rbp),%eax
movslq -0xc(%rbp),%rdi
cltd
idivl  (%rsi,%rdi,4)
mov    -0x40(%rbp),%rdx
mov    %eax,%esi
movslq -0xc(%rbp),%rax
mov    %esi,(%rcx,%rax,4)
mov    -0x2c(%rbp),%eax
movslq -0xc(%rbp),%rsi
mov    (%rcx,%rsi,4),%ecx
movslq -0xc(%rbp),%rsi
imul   (%rdx,%rsi,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1233 <main+0x113>
cmpl   $0x0,-0x2c(%rbp)
jne    12f7 <main+0x1d7>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f2 <main+0x1d2>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
movslq -0xc(%rbp),%rdx
mov    (%rcx,%rdx,4),%esi
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12b4 <main+0x194>
jmp    1305 <main+0x1e5>
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1030 <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    $0x18,%rsp
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9c(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1060 <scanf@plt>
mov    %rsp,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    -0x2c(%rbp),%edx
mov    %rsp,%r14
lea    0xf(,%rdx,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
test   %edx,%edx
jle    11b3 <main+0x73>
shl    $0x2,%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11fc <main+0xbc>
xor    %r12d,%r12d
lea    0xe31(%rip),%r15
mov    %r13,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%r12
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r12
jl     11e0 <main+0xa0>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf1(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
test   %edx,%edx
jle    1250 <main+0x110>
test   %ecx,%ecx
jle    1250 <main+0x110>
mov    $0x1,%esi
nopl   0x0(%rax,%rax,1)
mov    %edx,%eax
cltd
idivl  -0x4(%r13,%rsi,4)
mov    %eax,-0x4(%r14,%rsi,4)
test   %edx,%edx
jle    124d <main+0x10d>
lea    0x1(%rsi),%rax
cmp    %rcx,%rsi
mov    %rax,%rsi
jb     1230 <main+0xf0>
mov    %edx,-0x30(%rbp)
mov    -0x38(%rbp),%r12
test   %edx,%edx
je     1266 <main+0x126>
lea    0xe02(%rip),%rdi
call   1030 <puts@plt>
jmp    12a0 <main+0x160>
test   %ecx,%ecx
jle    12a0 <main+0x160>
lea    0xd92(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,4),%esi
mov    (%r14,%rbx,4),%edx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     1280 <main+0x140>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Enter Number of Denominations \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [42 x i8] c"Enter Denominations in descending order \0A\00"
@.str.3 = [13 x i8] c"Enter Bill \0A\00"
@.str.4 = [10 x i8] c"%d * %d \0A\00"
@.str.5 = [22 x i8] c"Bill cannot be paid \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %4
%13 = alloca i32, i64 %11
store i64 %11, i64* %5
%14 = load i32, i32* %2
%15 = zext i32 %14 to i64
%16 = alloca i32, i64 %15
store i64 %15, i64* %6
store i32 0, i32* %3
br label %17
17: ; preds = %25, %0
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %16, i64 %23
store i32 0, i32* %24
br label %25
25: ; preds = %21
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %17
28: ; preds = %17
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %30
30: ; preds = %39, %28
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %42
34: ; preds = %30
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %13, i64 %36
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %37)
br label %39
39: ; preds = %34
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %30
42: ; preds = %30
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
store i32 0, i32* %3
br label %45
45: ; preds = %54, %42
%46 = load i32, i32* %7
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = load i32, i32* %3
%50 = load i32, i32* %2
%51 = icmp slt i32 %49, %50
br label %52
52: ; preds = %48, %45
%53 = phi i1 [ false, %45 ], [ %51, %48 ]
br i1 %53, label %54, label %77
54: ; preds = %52
%55 = load i32, i32* %7
%56 = load i32, i32* %3
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %13, i64 %57
%59 = load i32, i32* %58
%60 = sdiv i32 %55, %59
%61 = load i32, i32* %3
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %16, i64 %62
store i32 %60, i32* %63
%64 = load i32, i32* %7
%65 = load i32, i32* %3
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %16, i64 %66
%68 = load i32, i32* %67
%69 = load i32, i32* %3
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %13, i64 %70
%72 = load i32, i32* %71
%73 = mul nsw i32 %68, %72
%74 = sub nsw i32 %64, %73
store i32 %74, i32* %7
%75 = load i32, i32* %3
%76 = add nsw i32 %75, 1
store i32 %76, i32* %3
br label %45
77: ; preds = %52
%78 = load i32, i32* %7
%79 = icmp eq i32 %78, 0
br i1 %79, label %80, label %99
80: ; preds = %77
store i32 0, i32* %3
br label %81
81: ; preds = %95, %80
%82 = load i32, i32* %3
%83 = load i32, i32* %2
%84 = icmp slt i32 %82, %83
br i1 %84, label %85, label %98
85: ; preds = %81
%86 = load i32, i32* %3
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %13, i64 %87
%89 = load i32, i32* %88
%90 = load i32, i32* %3
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i32, i32* %16, i64 %91
%93 = load i32, i32* %92
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %89, i32 %93)
br label %95
95: ; preds = %85
%96 = load i32, i32* %3
%97 = add nsw i32 %96, 1
store i32 %97, i32* %3
br label %81
98: ; preds = %81
br label %101
99: ; preds = %77
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %101
101: ; preds = %99, %98
store i32 0, i32* %1
%102 = load i8*, i8** %4
%103 = load i32, i32* %1
ret i32 %103
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [10 x i8] c"%d * %d \0A\00"
@str = [31 x i8] c"Enter Number of Denominations \00"
@str.6 = [41 x i8] c"Enter Denominations in descending order \00"
@str.7 = [12 x i8] c"Enter Bill \00"
@str.8 = [21 x i8] c"Bill cannot be paid \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
%9 = alloca i32, i64 %7
%10 = load i32, i32* %1
%11 = zext i32 %10 to i64
%12 = alloca i32, i64 %11
%13 = icmp sgt i32 %10, 0
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = bitcast i32* %12 to i8*
%16 = shl nuw nsw i64 %11, 2
br label %17
17: ; preds = %14, %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.6, i64 0, i64 0))
%19 = load i32, i32* %1
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %17, %21
%22 = phi i64 [ %25, %21 ], [ 0, %17 ]
%23 = getelementptr inbounds i32, i32* %9, i64 %22
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = add nuw nsw i64 %22, 1
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %21, label %29
29: ; preds = %21, %17
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.7, i64 0, i64 0))
%31 = bitcast i32* %2 to i8*
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%33 = load i32, i32* %2
%34 = load i32, i32* %1
%35 = icmp sgt i32 %33, 0
%36 = icmp sgt i32 %34, 0
%37 = select i1 %35, i1 %36, i1 false
br i1 %37, label %38, label %54
38: ; preds = %29
%39 = zext i32 %34 to i64
br label %40
40: ; preds = %38, %40
%41 = phi i64 [ 0, %38 ], [ %49, %40 ]
%42 = phi i32 [ %33, %38 ], [ %48, %40 ]
%43 = getelementptr inbounds i32, i32* %9, i64 %41
%44 = load i32, i32* %43
%45 = sdiv i32 %42, %44
%46 = getelementptr inbounds i32, i32* %12, i64 %41
store i32 %45, i32* %46
%47 = mul nsw i32 %45, %44
%48 = srem i32 %42, %44
%49 = add nuw nsw i64 %41, 1
%50 = icmp sgt i32 %48, 0
%51 = icmp ult i64 %49, %39
%52 = select i1 %50, i1 %51, i1 false
br i1 %52, label %40, label %53
53: ; preds = %40
store i32 %48, i32* %2
br label %54
54: ; preds = %53, %29
%55 = phi i32 [ %48, %53 ], [ %33, %29 ]
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %69
57: ; preds = %54
br i1 %36, label %58, label %71
58: ; preds = %57, %58
%59 = phi i64 [ %65, %58 ], [ 0, %57 ]
%60 = getelementptr inbounds i32, i32* %9, i64 %59
%61 = load i32, i32* %60
%62 = getelementptr inbounds i32, i32* %12, i64 %59
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %61, i32 %63)
%65 = add nuw nsw i64 %59, 1
%66 = load i32, i32* %1
%67 = sext i32 %66 to i64
%68 = icmp slt i64 %65, %67
br i1 %68, label %58, label %71
69: ; preds = %54
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.8, i64 0, i64 0))
br label %71
71: ; preds = %58, %57, %69
ret i32 0
}