#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
scalar_t__ random();
int /*<<< orphan*/ srandom(int);
int main() {
  srandom(2);
  int i;
  FILE *output;
  output = fopen("input", "w");
  for (i = 0; i < 100; i++)
    fprintf(output, "%d\n", (int)random() % (100 - 1) + 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x2,%edi
call   1030 <srandom@plt>
lea    0xea0(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    11b9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <random@plt>
mov    -0x18(%rbp),%rdi
mov    $0x63,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
lea    0xe62(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1177 <main+0x37>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x2,%edi
call   1030 <srandom@plt>
lea    0xeab(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    $0x64,%ebp
lea    0xe98(%rip),%r14
xor    %eax,%eax
call   1050 <random@plt>
cltq
imul   $0xffffffffa57eb503,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x63,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edx
add    $0x1,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
add    $0xffffffff,%ebp
jne    1170 <main+0x30>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"input\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 @srandom(i32 2)
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %10, %3 ]
%5 = tail call i64 (...) @random()
%6 = trunc i64 %5 to i32
%7 = srem i32 %6, 99
%8 = add nsw i32 %7, 1
%9 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = add nuw nsw i32 %4, 1
%11 = icmp eq i32 %10, 100
br i1 %11, label %12, label %3
12: ; preds = %3
ret i32 0
}