#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*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int);
int rand();
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ stdout;
int main(int argc, char const *argv[]) {
  freopen("test.txt", "w", stdout);
  srand(1);
  for (int i = 0; i < 100; ++i) {
    printf("%d %d", rand(), rand());
  }
  return 0;
}


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)
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
lea    0xe9a(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1040 <freopen@plt>
mov    $0x1,%edi
call   1050 <srand@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    11bd <main+0x7d>
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x18(%rbp),%esi
mov    %eax,%edx
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1183 <main+0x43>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e95(%rip),%rax
mov    (%rax),%edx
lea    0xeac(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1040 <freopen@plt>
mov    $0x1,%edi
call   1050 <srand@plt>
mov    $0x64,%ebx
lea    0xe95(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <rand@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printf@plt>
add    $0xffffffff,%ebx
jne    1180 <main+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.2 = [6 x i8] c"%d %d\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
%7 = load i32, i32* @stdout
%8 = call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 @srand(i32 1)
store i32 0, i32* %6
br label %10
10: ; preds = %17, %2
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 100
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = call i32 (...) @rand()
%15 = call i32 (...) @rand()
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %15)
br label %17
17: ; preds = %13
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %10
20: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.2 = [6 x i8] c"%d %d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdout
%4 = tail call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 @srand(i32 1)
br label %7
6: ; preds = %7
ret i32 0
7: ; preds = %2, %7
%8 = phi i32 [ 0, %2 ], [ %12, %7 ]
%9 = tail call i32 (...) @rand()
%10 = tail call i32 (...) @rand()
%11 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %10)
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i32 %12, 100
br i1 %13, label %6, label %7
}