#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();
void print_whitespace(int max_amount) {
  int i, amount;
  amount = rand() % max_amount;
  for (i = 0; i < amount; i++) {
    switch (rand() % 2) {
    case 0:
      printf(" ");
      break;
    case 1:
      printf("\t");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<print_whitespace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cltd
idivl  -0x4(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b0 <print_whitespace+0x90>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%edx
shr    $0x1f,%edx
mov    %eax,%ecx
add    %edx,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
je     1180 <print_whitespace+0x60>
jmp    116f <print_whitespace+0x4f>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     1191 <print_whitespace+0x71>
jmp    119d <print_whitespace+0x7d>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
jmp    119d <print_whitespace+0x7d>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
jmp    11a2 <print_whitespace+0x82>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1140 <print_whitespace+0x20>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_whitespace>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <rand@plt>
cltd
idiv   %ebx
test   %edx,%edx
jle    1170 <print_whitespace+0x50>
mov    %edx,%ebx
jmp    114f <print_whitespace+0x2f>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
je     1170 <print_whitespace+0x50>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
je     1140 <print_whitespace+0x20>
cmp    $0x1,%eax
jne    114a <print_whitespace+0x2a>
mov    $0x9,%edi
jmp    1145 <print_whitespace+0x25>
pop    %rbx
ret

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

LLVM IR (-O2):
define void @print_whitespace(i32 %0) {
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, %0
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %1, %13
%6 = phi i32 [ %14, %13 ], [ 0, %1 ]
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 2
switch i32 %8, label %13 [
i32 0, label %10
i32 1, label %9
]
9: ; preds = %5
br label %10
10: ; preds = %5, %9
%11 = phi i32 [ 9, %9 ], [ 32, %5 ]
%12 = tail call i32 @putchar(i32 %11)
br label %13
13: ; preds = %10, %5
%14 = add nuw nsw i32 %6, 1
%15 = icmp eq i32 %14, %3
br i1 %15, label %16, label %5
16: ; preds = %13, %1
ret void
}