#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int rand();
int main(int argc, char *argv[]) {
  for (int num = 0; num < 100; ++num) {
    int randVal = rand() % 10;
    if (randVal == 0) {
      puts("set breakpoint here.");
    }
    printf("Result: %d\n", num / randVal);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    11a2 <main+0x72>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    117f <main+0x4f>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,%esi
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
mov    0x2e37(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%r14
lea    0xed0(%rip),%r15
xor    %ebp,%ebp
jmp    1169 <main+0x39>
nopl   0x0(%rax)
movsbl %bpl,%eax
idiv   %bl
movsbl %al,%esi
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x64,%ebp
je     119a <main+0x6a>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
jne    1150 <main+0x20>
mov    %r14,%rdi
call   1030 <puts@plt>
jmp    1150 <main+0x20>
mov    0x2e3f(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"set breakpoint here.\00"
@.str.1 = [12 x i8] c"Result: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %8
8: ; preds = %23, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 100
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 10
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = sdiv i32 %19, %20
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %8
26: ; preds = %8
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}

LLVM IR (-O2):
@.str = [21 x i8] c"set breakpoint here.\00"
@.str.1 = [12 x i8] c"Result: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %5
3: ; preds = %12
%4 = load i32, i32* @EXIT_SUCCESS
ret i32 %4
5: ; preds = %2, %12
%6 = phi i32 [ 0, %2 ], [ %18, %12 ]
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 10
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %5
%13 = trunc i32 %6 to i8
%14 = trunc i32 %8 to i8
%15 = sdiv i8 %13, %14
%16 = sext i8 %15 to i32
%17 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i32 %6, 1
%19 = icmp eq i32 %18, 100
br i1 %19, label %3, label %5
}