#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 rand();
int main(void) {
  int i;
  int r;
  for (i = 1; i <= 100; i++) {
    r = rand() % 100;
    printf("%2d ", r);
    if (i % 10 == 0) {
      printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jg     1198 <main+0x78>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1185 <main+0x65>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118a <main+0x6a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r15b
lea    0xebf(%rip),%r14
xor    %ebp,%ebp
jmp    115c <main+0x2c>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffff,%ebp
add    $0x1,%r15b
cmp    $0xffffff9c,%ebp
je     11b2 <main+0x82>
movzbl %r15b,%eax
imul   $0xcd,%eax,%eax
shr    $0xa,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rax,4),%ebx
neg    %ebx
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
or     $0x1,%bl
cmp    %bpl,%bl
jne    1150 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%2d \00"
define i32 @main() {
br label %1
1: ; preds = %0, %11
%2 = phi i32 [ 1, %0 ], [ %12, %11 ]
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 100
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = trunc i32 %2 to i8
%7 = urem i8 %6, 10
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = tail call i32 @putchar(i32 10)
br label %11
11: ; preds = %1, %9
%12 = add nuw nsw i32 %2, 1
%13 = icmp eq i32 %12, 101
br i1 %13, label %14, label %1
14: ; preds = %11
ret i32 0
}