#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 arc4random();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, char);
int main(int argc, char *argv[]) {
  int i;
  for (i = 0; i < 1024; ++i) {
    printf("%08x%c", arc4random(), (i & 15) == 15 ? '\n' : ' ');
  }
  perror("write");
}


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   $0x400,-0x14(%rbp)
jge    1196 <main+0x66>
mov    $0x0,%al
call   1030 <arc4random@plt>
mov    %eax,%esi
mov    -0x14(%rbp),%edx
and    $0xf,%edx
mov    $0x20,%eax
mov    $0xa,%ecx
cmp    $0xf,%edx
cmove  %ecx,%eax
lea    0xe80(%rip),%rdi
movsbl %al,%edx
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
lea    0xe6a(%rip),%rdi
call   1050 <perror@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0xa,%r14d
lea    0xebf(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <arc4random@plt>
mov    %ebp,%ecx
not    %ecx
test   $0xf,%cl
mov    $0x20,%edx
cmove  %r14d,%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x400,%ebp
jne    1150 <main+0x20>
lea    0xe84(%rip),%rdi
call   1050 <perror@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%08x%c\00"
@.str.1 = [6 x i8] c"write\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %7
7: ; preds = %19, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 1024
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = call i32 (...) @arc4random()
%12 = load i32, i32* %6
%13 = and i32 %12, 15
%14 = icmp eq i32 %13, 15
%15 = zext i1 %14 to i64
%16 = select i1 %14, i32 10, i32 32
%17 = trunc i32 %16 to i8
%18 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %11, i8 signext %17)
br label %19
19: ; preds = %10
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %7
22: ; preds = %7
%23 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [7 x i8] c"%08x%c\00"
@.str.1 = [6 x i8] c"write\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %10, %3 ]
%5 = tail call i32 (...) @arc4random()
%6 = and i32 %4, 15
%7 = icmp eq i32 %6, 15
%8 = select i1 %7, i8 10, i8 32
%9 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %5, i8 signext %8)
%10 = add nuw nsw i32 %4, 1
%11 = icmp eq i32 %10, 1024
br i1 %11, label %12, label %3
12: ; preds = %3
%13 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}