#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 num;
  printf("do-while Loop Example 2\n\n");
  do {
    printf("Enter a number from 1 to 10: ");
    scanf("%d", &num);
    if (num < 1 || num > 10)
      printf("Number is not in proper range!\n");
  } while (num < 1 || num > 10);
  printf("\nYou entered %d.\n\n", num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     116f <main+0x4f>
cmpl   $0xa,-0x8(%rbp)
jle    117d <main+0x5d>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1182 <main+0x62>
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jl     119b <main+0x7b>
cmpl   $0xa,-0x8(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    113d <main+0x1d>
mov    -0x8(%rbp),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%r14
lea    0xecc(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xeef(%rip),%r12
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
lea    -0xb(%rsi),%eax
cmp    $0xfffffff5,%eax
ja     1195 <main+0x65>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%esi
lea    -0xb(%rsi),%eax
cmp    $0xfffffff6,%eax
jb     1160 <main+0x30>
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"do-while Loop Example 2\0A\0A\00"
@.str.1 = [30 x i8] c"Enter a number from 1 to 10: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [32 x i8] c"Number is not in proper range!\0A\00"
@.str.4 = [19 x i8] c"\0AYou entered %d.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %21, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 10
br i1 %11, label %12, label %14
12: ; preds = %9, %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
br label %15
15: ; preds = %14
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 1
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 10
br label %21
21: ; preds = %18, %15
%22 = phi i1 [ true, %15 ], [ %20, %18 ]
br i1 %22, label %4, label %23
23: ; preds = %21
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c"Enter a number from 1 to 10: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [19 x i8] c"\0AYou entered %d.\0A\0A\00"
@str = [25 x i8] c"do-while Loop Example 2\0A\00"
@str.5 = [31 x i8] c"Number is not in proper range!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %10, %0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = add i32 %7, -11
%9 = icmp ult i32 %8, -10
br i1 %9, label %10, label %15
10: ; preds = %4
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.5, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = add i32 %12, -11
%14 = icmp ult i32 %13, -10
br i1 %14, label %4, label %15
15: ; preds = %4, %10
%16 = phi i32 [ %12, %10 ], [ %7, %4 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %16)
ret i32 0
}