#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 const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, const char *argv[]) {
  srand(time(NULL));
  FILE *in;
  in = fopen(argv[1], "a");
  long int i;
  for (i = 0; i < 1000; i++) {
    fprintf(in, "%i.%i ", rand() % 1000, rand() % 1000);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x3e8,-0x20(%rbp)
jge    11f3 <main+0xa3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    -0x30(%rbp),%rdi
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x24(%rbp),%edx
lea    0xe25(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1196 <main+0x46>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    0x8(%rbx),%rdi
lea    0xe8c(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    $0x3e8,%r12d
lea    0xe79(%rip),%r14
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%rbx
imul   $0x10624dd3,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%rcx
imul   $0x10624dd3,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rax
add    %edx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <fprintf@plt>
add    $0xffffffffffffffff,%r12
jne    1190 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@.str.1 = [7 x i8] c"%i.%i \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @time(i32* null)
%9 = call i32 @srand(i32 %8)
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
store i64 0, i64* %7
br label %14
14: ; preds = %24, %2
%15 = load i64, i64* %7
%16 = icmp slt i64 %15, 1000
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load i32*, i32** %6
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 1000
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 1000
%23 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %22)
br label %24
24: ; preds = %17
%25 = load i64, i64* %7
%26 = add nsw i64 %25, 1
store i64 %26, i64* %7
br label %14
27: ; preds = %14
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@.str.1 = [7 x i8] c"%i.%i \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %2, %8
%9 = phi i64 [ 0, %2 ], [ %15, %8 ]
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 1000
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 1000
%14 = tail call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %13)
%15 = add nuw nsw i64 %9, 1
%16 = icmp eq i64 %15, 1000
br i1 %16, label %17, label %8
17: ; preds = %8
ret i32 0
}