#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int fl, n, i;
  FILE *f;
  f = freopen("01.2.dat", "w", stdout);
  fl = 0;
  n = 100000;
  printf("%d %d %d ", 78, 112, n);
  for (i = 0; i < n; i++) {
    if (i % 2 == fl)
      printf("1 ");
    else
      printf("2 ");
  }
  fclose(f);
  f = freopen("01.1.dat", "w", stdout);
  fl = 1;
  n = 100000;
  printf("%d %d %d ", 79, 111, n);
  for (i = 0; i < n; i++) {
    if (i % 2 == fl)
      printf("1 ");
    else
      printf("2 ");
  }
  return 0;
}


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)
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
lea    0xeaa(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1050 <freopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x186a0,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
lea    0xe8d(%rip),%rdi
mov    $0x4e,%esi
mov    $0x70,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11ea <main+0xba>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    -0x14(%rbp),%edx
jne    11c9 <main+0x99>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d7 <main+0xa7>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11dc <main+0xac>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1196 <main+0x66>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edx
lea    0xe18(%rip),%rdi
lea    0xdff(%rip),%rsi
call   1050 <freopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x186a0,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
lea    0xde0(%rip),%rdi
mov    $0x4f,%esi
mov    $0x6f,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1297 <main+0x167>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    -0x14(%rbp),%edx
jne    1276 <main+0x146>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1284 <main+0x154>
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1289 <main+0x159>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1243 <main+0x113>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2ea1(%rip),%r12
mov    (%r12),%edx
lea    0xeb6(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1050 <freopen@plt>
mov    %rax,%r14
lea    0xeab(%rip),%rdi
mov    $0x4e,%esi
mov    $0x70,%edx
mov    $0x186a0,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe98(%rip),%r15
lea    0xe94(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
test   $0x1,%bpl
mov    %rbx,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x186a0,%ebp
jne    1190 <main+0x60>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    (%r12),%edx
lea    0xe5b(%rip),%rdi
lea    0xe42(%rip),%rsi
call   1050 <freopen@plt>
lea    0xe38(%rip),%rdi
mov    $0x4f,%esi
mov    $0x6f,%edx
mov    $0x186a0,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
test   $0x1,%bpl
mov    %r15,%rdi
cmove  %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x186a0,%ebp
jne    11f0 <main+0xc0>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"01.2.dat\00"
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.2 = [10 x i8] c"%d %d %d \00"
@.str.3 = [3 x i8] c"1 \00"
@.str.4 = [3 x i8] c"2 \00"
@.str.5 = [9 x i8] c"01.1.dat\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @stdout
%11 = 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 %10)
store i32* %11, i32** %9
store i32 0, i32* %6
store i32 100000, i32* %7
%12 = load i32, i32* %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 78, i32 112, i32 %12)
store i32 0, i32* %8
br label %14
14: ; preds = %28, %2
%15 = load i32, i32* %8
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %31
18: ; preds = %14
%19 = load i32, i32* %8
%20 = srem i32 %19, 2
%21 = load i32, i32* %6
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %27
25: ; preds = %18
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
br label %28
28: ; preds = %27
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %14
31: ; preds = %14
%32 = load i32*, i32** %9
%33 = call i32 @fclose(i32* %32)
%34 = load i32, i32* @stdout
%35 = call i32* @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %34)
store i32* %35, i32** %9
store i32 1, i32* %6
store i32 100000, i32* %7
%36 = load i32, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 79, i32 111, i32 %36)
store i32 0, i32* %8
br label %38
38: ; preds = %52, %31
%39 = load i32, i32* %8
%40 = load i32, i32* %7
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %55
42: ; preds = %38
%43 = load i32, i32* %8
%44 = srem i32 %43, 2
%45 = load i32, i32* %6
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %51
49: ; preds = %42
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
br label %52
52: ; preds = %51
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 1
store i32 %54, i32* %8
br label %38
55: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"01.2.dat\00"
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.2 = [10 x i8] c"%d %d %d \00"
@.str.3 = [3 x i8] c"1 \00"
@.str.4 = [3 x i8] c"2 \00"
@.str.5 = [9 x i8] c"01.1.dat\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 78, i32 112, i32 100000)
br label %6
6: ; preds = %2, %6
%7 = phi i32 [ 0, %2 ], [ %12, %6 ]
%8 = and i32 %7, 1
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %10)
%12 = add nuw nsw i32 %7, 1
%13 = icmp eq i32 %12, 100000
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = tail call i32 @fclose(i32* %4)
%16 = load i32, i32* @stdout
%17 = tail call i32* @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 79, i32 111, i32 100000)
br label %19
19: ; preds = %14, %19
%20 = phi i32 [ 0, %14 ], [ %25, %19 ]
%21 = and i32 %20, 1
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %23)
%25 = add nuw nsw i32 %20, 1
%26 = icmp eq i32 %25, 100000
br i1 %26, label %27, label %19
27: ; preds = %19
ret i32 0
}