#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 *);
main() {
  int bookId = 0, invStart = 0, invAdd = 0, invSold = 0, count = 1;
  while (count <= 3) {
    printf("\nPlease enter your Book's identification number --> ");
    scanf("%d", &bookId);
    printf("\nPlease enter Book's starting inventory --> ");
    scanf("%d", &invStart);
    printf("\nPlease enter Books added to inventory --> ");
    scanf("%d", &invAdd);
    printf("\nPlease enter Books sold --> ");
    scanf("%d", &invSold);
    printf(
        "\nID:%d New Balance: %d = inentory balance at the beginning of the "
        "month: %d.\n            + Number of copies received during the month: "
        "%d.\n            - Number of copies sold during the month: %d.\n",
        bookId, invStart + invAdd - invSold, invStart, invAdd, invSold);
    count++;
  }
  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)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jg     1207 <main+0xe7>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe88(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6a(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
add    -0x10(%rbp),%edx
sub    -0x14(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1152 <main+0x32>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed2(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xed3(%rip),%r13
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x14(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
lea    0xede(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
mov    0x14(%rsp),%r8d
lea    (%r8,%rcx,1),%edx
mov    0x10(%rsp),%r9d
sub    %r9d,%edx
lea    0xec2(%rip),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe02(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
mov    0x14(%rsp),%r8d
lea    (%r8,%rcx,1),%edx
mov    0x10(%rsp),%r9d
sub    %r9d,%edx
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd7f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xd9c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
mov    0x14(%rsp),%r8d
lea    (%r8,%rcx,1),%edx
mov    0x10(%rsp),%r9d
sub    %r9d,%edx
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"\0APlease enter your Book's identification number --> \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [45 x i8] c"\0APlease enter Book's starting inventory --> \00"
@.str.3 = [44 x i8] c"\0APlease enter Books added to inventory --> \00"
@.str.4 = [30 x i8] c"\0APlease enter Books sold --> \00"
@.str.5 = [198 x i8] c"\0AID:%d New Balance: %d = inentory balance at the beginning of the month: %d.\0A + Number of copies received during the month: %d.\0A - Number of copies sold during the month: %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 1, i32* %6
br label %7
7: ; preds = %10, %0
%8 = load i32, i32* %6
%9 = icmp sle i32 %8, 3
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = add nsw i32 %20, %21
%23 = load i32, i32* %5
%24 = sub nsw i32 %22, %23
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([198 x i8], [198 x i8]* @.str.5, i64 0, i64 0), i32 %19, i32 %24, i32 %25, i32 %26, i32 %27)
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %7
31: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [53 x i8] c"\0APlease enter your Book's identification number --> \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [45 x i8] c"\0APlease enter Book's starting inventory --> \00"
@.str.3 = [44 x i8] c"\0APlease enter Books added to inventory --> \00"
@.str.4 = [30 x i8] c"\0APlease enter Books sold --> \00"
@.str.5 = [198 x i8] c"\0AID:%d New Balance: %d = inentory balance at the beginning of the month: %d.\0A + Number of copies received during the month: %d.\0A - Number of copies sold during the month: %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = add nsw i32 %19, %18
%21 = load i32, i32* %4
%22 = sub i32 %20, %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([198 x i8], [198 x i8]* @.str.5, i64 0, i64 0), i32 %17, i32 %22, i32 %18, i32 %19, i32 %21)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%32 = load i32, i32* %1
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = add nsw i32 %34, %33
%36 = load i32, i32* %4
%37 = sub i32 %35, %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([198 x i8], [198 x i8]* @.str.5, i64 0, i64 0), i32 %32, i32 %37, i32 %33, i32 %34, i32 %36)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 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* %3)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%47 = load i32, i32* %1
%48 = load i32, i32* %2
%49 = load i32, i32* %3
%50 = add nsw i32 %49, %48
%51 = load i32, i32* %4
%52 = sub i32 %50, %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([198 x i8], [198 x i8]* @.str.5, i64 0, i64 0), i32 %47, i32 %52, i32 %48, i32 %49, i32 %51)
ret i32 0
}