#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() {
  int total = 0, cur = 0, coins = 0;
  printf("Total amount: ");
  scanf("%d", &total);
  printf("\n");
  int i = 7;
  for (i = 7; i > 0; i -= 2) {
    coins = (total - cur) / i;
    cur += coins * i;
    printf("%d %d-cent coins = %d\n", coins, i, cur);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x7,-0x14(%rbp)
movl   $0x7,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11c7 <main+0xa7>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <main+0x5e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movslq 0xc(%rsp),%rax
imul   $0xffffffff92492493,%rax,%rsi
shr    $0x20,%rsi
add    %eax,%esi
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0x2,%esi
add    %eax,%esi
lea    0x0(,%rsi,8),%ebp
sub    %esi,%ebp
lea    0xe7d(%rip),%r14
mov    %r14,%rdi
mov    $0x7,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
sub    %ebp,%eax
cltq
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
shr    $0x20,%rsi
sar    %esi
add    %eax,%esi
lea    (%rsi,%rsi,4),%ebx
add    %ebp,%ebx
mov    %r14,%rdi
mov    $0x5,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
sub    %ebx,%eax
cltq
imul   $0x55555556,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
shr    $0x20,%rsi
add    %eax,%esi
lea    (%rsi,%rsi,2),%ebp
add    %ebx,%ebp
mov    %r14,%rdi
mov    $0x3,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ecx
mov    %ecx,%esi
sub    %ebp,%esi
mov    %r14,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Total amount: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [23 x i8] c"%d %d-cent coins = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 7, i32* %5
store i32 7, i32* %5
br label %9
9: ; preds = %27, %0
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = sub nsw i32 %13, %14
%16 = load i32, i32* %5
%17 = sdiv i32 %15, %16
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = mul nsw i32 %18, %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, %20
store i32 %22, i32* %3
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %23, i32 %24, i32 %25)
br label %27
27: ; preds = %12
%28 = load i32, i32* %5
%29 = sub nsw i32 %28, 2
store i32 %29, i32* %5
br label %9
30: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Total amount: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [23 x i8] c"%d %d-cent coins = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 @putchar(i32 10)
%6 = load i32, i32* %1
%7 = sdiv i32 %6, 7
%8 = mul nsw i32 %7, 7
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 7, i32 %8)
%10 = load i32, i32* %1
%11 = sub nsw i32 %10, %8
%12 = sdiv i32 %11, 5
%13 = mul nsw i32 %12, 5
%14 = add nsw i32 %13, %8
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %12, i32 5, i32 %14)
%16 = load i32, i32* %1
%17 = sub nsw i32 %16, %14
%18 = sdiv i32 %17, 3
%19 = mul nsw i32 %18, 3
%20 = add nsw i32 %19, %14
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 3, i32 %20)
%22 = load i32, i32* %1
%23 = sub nsw i32 %22, %20
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %23, i32 1, i32 %22)
ret i32 0
}