#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);
void decoupure(int solde) {
  int i = 0, j = 0;
  int coupure[] = {500, 200, 100, 50, 20, 10, 5, 2, 1};
  int peut_couper = 1;
  for (i; i < 9; i++) {
    while (peut_couper) {
      if (solde - coupure[i] >= 0) {
        solde -= coupure[i];
        printf("%d ", coupure[i]);
      } else {
        peut_couper = 0;
      }
    }
    peut_couper = 1;
  }
}


x86 assembly (clang, -O0):
<decoupure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xebc(%rip),%rsi
mov    $0x24,%edx
call   1040 <memcpy@plt>
movl   $0x1,-0x34(%rbp)
cmpl   $0x9,-0x8(%rbp)
jge    11cc <decoupure+0xac>
jmp    1164 <decoupure+0x44>
cmpl   $0x0,-0x34(%rbp)
je     11b7 <decoupure+0x97>
mov    -0x4(%rbp),%eax
movslq -0x8(%rbp),%rcx
sub    -0x30(%rbp,%rcx,4),%eax
cmp    $0x0,%eax
jl     11ab <decoupure+0x8b>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
jmp    11b2 <decoupure+0x92>
movl   $0x0,-0x34(%rbp)
jmp    1164 <decoupure+0x44>
movl   $0x1,-0x34(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1155 <decoupure+0x35>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decoupure>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
cmp    $0x1f4,%edi
jl     129d <decoupure+0x18d>
lea    0xed7(%rip),%r14
nopl   0x0(%rax)
lea    -0x1f4(%rbp),%ebx
mov    %r14,%rdi
mov    $0x1f4,%esi
call   1030 <printf@plt>
cmp    $0x3e7,%ebp
mov    %ebx,%ebp
jg     1130 <decoupure+0x20>
cmp    $0xc8,%ebx
jl     12ab <decoupure+0x19b>
lea    0xea0(%rip),%r14
lea    -0xc8(%rbx),%ebp
mov    %r14,%rdi
mov    $0xc8,%esi
call   1030 <printf@plt>
cmp    $0x18f,%ebx
mov    %ebp,%ebx
jg     1160 <decoupure+0x50>
cmp    $0x64,%ebp
jl     12b6 <decoupure+0x1a6>
lea    0xe73(%rip),%r14
nopl   (%rax)
lea    -0x64(%rbp),%ebx
mov    %r14,%rdi
mov    $0x64,%esi
call   1030 <printf@plt>
cmp    $0xc7,%ebp
mov    %ebx,%ebp
jg     1190 <decoupure+0x80>
cmp    $0x32,%ebx
jl     12c1 <decoupure+0x1b1>
lea    0xe46(%rip),%r14
nopw   0x0(%rax,%rax,1)
lea    -0x32(%rbx),%ebp
mov    %r14,%rdi
mov    $0x32,%esi
call   1030 <printf@plt>
cmp    $0x63,%ebx
mov    %ebp,%ebx
jg     11c0 <decoupure+0xb0>
cmp    $0x14,%ebp
jl     12cc <decoupure+0x1bc>
lea    0xe19(%rip),%r14
nopw   0x0(%rax,%rax,1)
lea    -0x14(%rbp),%ebx
mov    %r14,%rdi
mov    $0x14,%esi
call   1030 <printf@plt>
cmp    $0x27,%ebp
mov    %ebx,%ebp
jg     11f0 <decoupure+0xe0>
cmp    $0xa,%ebx
jl     12d7 <decoupure+0x1c7>
lea    0xde9(%rip),%r14
nopw   0x0(%rax,%rax,1)
lea    -0xa(%rbx),%ebp
mov    %r14,%rdi
mov    $0xa,%esi
call   1030 <printf@plt>
cmp    $0x13,%ebx
mov    %ebp,%ebx
jg     1220 <decoupure+0x110>
cmp    $0x5,%ebp
jl     12e2 <decoupure+0x1d2>
lea    0xdb9(%rip),%r14
nopw   0x0(%rax,%rax,1)
lea    -0x5(%rbp),%ebx
mov    %r14,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
cmp    $0x9,%ebp
mov    %ebx,%ebp
jg     1250 <decoupure+0x140>
cmp    $0x2,%ebx
jl     12e9 <decoupure+0x1d9>
lea    0xd8d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x2(%rbx),%ebp
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
cmp    $0x3,%ebx
mov    %ebp,%ebx
jg     1280 <decoupure+0x170>
test   %ebp,%ebp
jg     12ef <decoupure+0x1df>
jmp    1315 <decoupure+0x205>
mov    %ebp,%ebx
cmp    $0xc8,%ebx
jge    1159 <decoupure+0x49>
mov    %ebx,%ebp
cmp    $0x64,%ebp
jge    1186 <decoupure+0x76>
mov    %ebp,%ebx
cmp    $0x32,%ebx
jge    11b3 <decoupure+0xa3>
mov    %ebx,%ebp
cmp    $0x14,%ebp
jge    11e0 <decoupure+0xd0>
mov    %ebp,%ebx
cmp    $0xa,%ebx
jge    1210 <decoupure+0x100>
mov    %ebx,%ebp
cmp    $0x5,%ebp
jge    1240 <decoupure+0x130>
mov    %ebp,%ebx
cmp    $0x2,%ebx
jge    126c <decoupure+0x15c>
mov    %ebx,%ebp
test   %ebp,%ebp
jle    1315 <decoupure+0x205>
add    $0x1,%ebp
lea    0xd07(%rip),%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jg     1300 <decoupure+0x1f0>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.decoupure.coupure = [9 x i32] [i32 500, i32 200, i32 100, i32 50, i32 20, i32 10, i32 5, i32 2, i32 1]
@.str = [4 x i8] c"%d \00"
define void @decoupure(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [9 x i32]
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%7 = bitcast [9 x i32]* %5 to i8*
store i32 1, i32* %6
%8 = load i32, i32* %3
br label %9
9: ; preds = %39, %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 9
br i1 %11, label %12, label %42
12: ; preds = %9
br label %13
13: ; preds = %37, %12
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %38
16: ; preds = %13
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = sub nsw i32 %17, %21
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %36
24: ; preds = %16
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = load i32, i32* %2
%30 = sub nsw i32 %29, %28
store i32 %30, i32* %2
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %34)
br label %37
36: ; preds = %16
store i32 0, i32* %6
br label %37
37: ; preds = %36, %24
br label %13
38: ; preds = %13
store i32 1, i32* %6
br label %39
39: ; preds = %38
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %9
42: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @decoupure(i32 %0) {
%2 = icmp sgt i32 %0, 499
br i1 %2, label %6, label %3
3: ; preds = %6, %1
%4 = phi i32 [ %0, %1 ], [ %8, %6 ]
%5 = icmp sgt i32 %4, 199
br i1 %5, label %14, label %11
6: ; preds = %1, %6
%7 = phi i32 [ %8, %6 ], [ %0, %1 ]
%8 = add nsw i32 %7, -500
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 500)
%10 = icmp sgt i32 %7, 999
br i1 %10, label %6, label %3
11: ; preds = %14, %3
%12 = phi i32 [ %4, %3 ], [ %16, %14 ]
%13 = icmp sgt i32 %12, 99
br i1 %13, label %22, label %19
14: ; preds = %3, %14
%15 = phi i32 [ %16, %14 ], [ %4, %3 ]
%16 = add nsw i32 %15, -200
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 200)
%18 = icmp sgt i32 %15, 399
br i1 %18, label %14, label %11
19: ; preds = %22, %11
%20 = phi i32 [ %12, %11 ], [ %24, %22 ]
%21 = icmp sgt i32 %20, 49
br i1 %21, label %30, label %27
22: ; preds = %11, %22
%23 = phi i32 [ %24, %22 ], [ %12, %11 ]
%24 = add nsw i32 %23, -100
%25 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 100)
%26 = icmp sgt i32 %23, 199
br i1 %26, label %22, label %19
27: ; preds = %30, %19
%28 = phi i32 [ %20, %19 ], [ %32, %30 ]
%29 = icmp sgt i32 %28, 19
br i1 %29, label %38, label %35
30: ; preds = %19, %30
%31 = phi i32 [ %32, %30 ], [ %20, %19 ]
%32 = add nsw i32 %31, -50
%33 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 50)
%34 = icmp sgt i32 %31, 99
br i1 %34, label %30, label %27
35: ; preds = %38, %27
%36 = phi i32 [ %28, %27 ], [ %40, %38 ]
%37 = icmp sgt i32 %36, 9
br i1 %37, label %46, label %43
38: ; preds = %27, %38
%39 = phi i32 [ %40, %38 ], [ %28, %27 ]
%40 = add nsw i32 %39, -20
%41 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 20)
%42 = icmp sgt i32 %39, 39
br i1 %42, label %38, label %35
43: ; preds = %46, %35
%44 = phi i32 [ %36, %35 ], [ %48, %46 ]
%45 = icmp sgt i32 %44, 4
br i1 %45, label %54, label %51
46: ; preds = %35, %46
%47 = phi i32 [ %48, %46 ], [ %36, %35 ]
%48 = add nsw i32 %47, -10
%49 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 10)
%50 = icmp sgt i32 %47, 19
br i1 %50, label %46, label %43
51: ; preds = %54, %43
%52 = phi i32 [ %44, %43 ], [ %56, %54 ]
%53 = icmp sgt i32 %52, 1
br i1 %53, label %62, label %59
54: ; preds = %43, %54
%55 = phi i32 [ %56, %54 ], [ %44, %43 ]
%56 = add nsw i32 %55, -5
%57 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 5)
%58 = icmp sgt i32 %55, 9
br i1 %58, label %54, label %51
59: ; preds = %62, %51
%60 = phi i32 [ %52, %51 ], [ %64, %62 ]
%61 = icmp sgt i32 %60, 0
br i1 %61, label %67, label %72
62: ; preds = %51, %62
%63 = phi i32 [ %64, %62 ], [ %52, %51 ]
%64 = add nsw i32 %63, -2
%65 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%66 = icmp sgt i32 %63, 3
br i1 %66, label %62, label %59
67: ; preds = %59, %67
%68 = phi i32 [ %69, %67 ], [ %60, %59 ]
%69 = add nsw i32 %68, -1
%70 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%71 = icmp sgt i32 %68, 1
br i1 %71, label %67, label %72
72: ; preds = %67, %59
ret void
}