#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);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int stock = 180;
  int order;
  while (stock > 0) {
    printf("%i glasses left\n", stock);
    scanf("%i", &order);
    printf("%x \n", order);
    stock = stock - order;
    printf("You ordered %i glasses\n", order);
  }
  puts("We're out of stock, baby!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xb4,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    119b <main+0x6b>
mov    -0x8(%rbp),%esi
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%esi
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
jmp    1146 <main+0x16>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xb4,%ebx
lea    0xeca(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xec1(%rip),%r13
lea    0xebf(%rip),%rbp
nopw   0x0(%rax,%rax,1)
lea    0xe99(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%r14d
mov    %rbp,%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
sub    %r14d,%ebx
jg     1160 <main+0x30>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"%i glasses left\0A\00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [5 x i8] c"%x \0A\00"
@.str.3 = [24 x i8] c"You ordered %i glasses\0A\00"
@.str.4 = [26 x i8] c"We're out of stock, baby!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 180, i32* %2
br label %4
4: ; preds = %7, %0
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = load i32, i32* %2
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = sub nsw i32 %13, %14
store i32 %15, i32* %2
%16 = load i32, i32* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %16)
br label %4
18: ; preds = %4
%19 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"%i glasses left\0A\00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [5 x i8] c"%x \0A\00"
@.str.3 = [24 x i8] c"You ordered %i glasses\0A\00"
@.str.4 = [26 x i8] c"We're out of stock, baby!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 180, %0 ], [ %10, %3 ]
%5 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %1
%10 = sub nsw i32 %4, %9
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%12 = icmp sgt i32 %10, 0
br i1 %12, label %3, label %13
13: ; preds = %3
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}