#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int main(int argc, char **argv) {
  FILE *fp;
  char filename[100];
  int rand1, rand2, rand3, randbool;
  int i;
  sprintf(filename, "q%d/c%d.txt", 28, 1);
  fp = fopen(filename, "w");
  for (i = 0; i < 150; i++) {
    rand1 = (rand() % 28) + 1;
    rand2 = (rand() % 28) + 1;
    while (rand2 == rand1) {
      rand2 = (rand() % 28) + 1;
    }
    rand3 = rand() % 28 + 1;
    while (rand3 == rand2 || rand3 == rand1) {
      rand3 = rand() % 28 + 1;
    }
    randbool = rand() % 2;
    if (randbool == 1)
      rand1 *= -1;
    randbool = rand() % 2;
    if (randbool == 1)
      rand2 *= -1;
    randbool = rand() % 2;
    if (randbool == 1)
      rand3 *= -1;
    fprintf(fp, "%d %d %d\n", rand1, rand2, rand3);
  }
  fclose(fp);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe8c(%rip),%rsi
mov    $0x1c,%edx
mov    $0x1,%ecx
call   1060 <sprintf@plt>
lea    -0x80(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x94(%rbp)
cmpl   $0x96,-0x94(%rbp)
jge    134b <main+0x1fb>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x1c,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x84(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x1c,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x88(%rbp)
mov    -0x88(%rbp),%eax
cmp    -0x84(%rbp),%eax
jne    1210 <main+0xc0>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x1c,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x88(%rbp)
jmp    11e1 <main+0x91>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x1c,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8c(%rbp)
mov    -0x8c(%rbp),%ecx
mov    $0x1,%al
cmp    -0x88(%rbp),%ecx
mov    %al,-0x95(%rbp)
je     1257 <main+0x107>
mov    -0x8c(%rbp),%eax
cmp    -0x84(%rbp),%eax
sete   %al
mov    %al,-0x95(%rbp)
mov    -0x95(%rbp),%al
test   $0x1,%al
jne    126a <main+0x11a>
jmp    1287 <main+0x137>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x1c,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8c(%rbp)
jmp    1228 <main+0xd8>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x90(%rbp)
cmpl   $0x1,-0x90(%rbp)
jne    12b6 <main+0x166>
imul   $0xffffffff,-0x84(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x90(%rbp)
cmpl   $0x1,-0x90(%rbp)
jne    12e5 <main+0x195>
imul   $0xffffffff,-0x88(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x90(%rbp)
cmpl   $0x1,-0x90(%rbp)
jne    1314 <main+0x1c4>
imul   $0xffffffff,-0x8c(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x84(%rbp),%edx
mov    -0x88(%rbp),%ecx
mov    -0x8c(%rbp),%r8d
lea    0xcdc(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11a1 <main+0x51>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe9b(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1c,%edx
mov    $0x1,%ecx
call   1060 <sprintf@plt>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
mov    %rax,0x8(%rsp)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r13d
movslq %eax,%rbx
imul   $0xffffffff92492493,%rbx,%rax
shr    $0x20,%rax
add    %r13d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x4,%eax
add    %ecx,%eax
lea    (%rax,%rax,8),%ecx
lea    (%rcx,%rcx,2),%r12d
add    %eax,%r12d
sub    %r12d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%r15
imul   $0xffffffff92492493,%r15,%rax
shr    $0x20,%rax
add    %r15d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x4,%eax
add    %ecx,%eax
lea    (%rax,%rax,8),%ecx
lea    (%rcx,%rcx,2),%ecx
add    %eax,%ecx
sub    %ecx,%r15d
cmp    %ebx,%r15d
je     11e0 <main+0x90>
neg    %r12d
lea    0x1(%r15),%eax
mov    %eax,0x4(%rsp)
nopl   (%rax)
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%rbp
imul   $0xffffffff92492493,%rbp,%rax
shr    $0x20,%rax
add    %ebp,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x4,%eax
add    %ecx,%eax
lea    (%rax,%rax,8),%ecx
lea    (%rcx,%rcx,2),%ecx
add    %eax,%ecx
sub    %ecx,%ebp
cmp    %r15d,%ebp
je     1220 <main+0xd0>
cmp    %ebx,%ebp
je     1220 <main+0xd0>
add    %r12d,%r13d
add    $0x1,%r13d
lea    0x1(%rbp),%r12d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
not    %ebx
cmovne %r13d,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
not    %r15d
mov    0x4(%rsp),%r13d
cmove  %r15d,%r13d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
not    %ebp
cmovne %r12d,%ebp
mov    0x8(%rsp),%rdi
lea    0xd49(%rip),%rsi
mov    %ebx,%edx
mov    %r13d,%ecx
mov    %ebp,%r8d
call   1040 <fprintf@plt>
add    $0x1,%r14d
cmp    $0x96,%r14d
jne    11a0 <main+0x50>
mov    0x8(%rsp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"q%d/c%d.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [10 x i8] c"%d %d %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [100 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%14 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 28, i32 1)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %6
store i32 0, i32* %12
br label %17
17: ; preds = %83, %2
%18 = load i32, i32* %12
%19 = icmp slt i32 %18, 150
br i1 %19, label %20, label %86
20: ; preds = %17
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 28
%23 = add nsw i32 %22, 1
store i32 %23, i32* %8
%24 = call i32 (...) @rand()
%25 = srem i32 %24, 28
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %27
27: ; preds = %31, %20
%28 = load i32, i32* %9
%29 = load i32, i32* %8
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = call i32 (...) @rand()
%33 = srem i32 %32, 28
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %27
35: ; preds = %27
%36 = call i32 (...) @rand()
%37 = srem i32 %36, 28
%38 = add nsw i32 %37, 1
store i32 %38, i32* %10
br label %39
39: ; preds = %49, %35
%40 = load i32, i32* %10
%41 = load i32, i32* %9
%42 = icmp eq i32 %40, %41
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = load i32, i32* %10
%45 = load i32, i32* %8
%46 = icmp eq i32 %44, %45
br label %47
47: ; preds = %43, %39
%48 = phi i1 [ true, %39 ], [ %46, %43 ]
br i1 %48, label %49, label %53
49: ; preds = %47
%50 = call i32 (...) @rand()
%51 = srem i32 %50, 28
%52 = add nsw i32 %51, 1
store i32 %52, i32* %10
br label %39
53: ; preds = %47
%54 = call i32 (...) @rand()
%55 = srem i32 %54, 2
store i32 %55, i32* %11
%56 = load i32, i32* %11
%57 = icmp eq i32 %56, 1
br i1 %57, label %58, label %61
58: ; preds = %53
%59 = load i32, i32* %8
%60 = mul nsw i32 %59, -1
store i32 %60, i32* %8
br label %61
61: ; preds = %58, %53
%62 = call i32 (...) @rand()
%63 = srem i32 %62, 2
store i32 %63, i32* %11
%64 = load i32, i32* %11
%65 = icmp eq i32 %64, 1
br i1 %65, label %66, label %69
66: ; preds = %61
%67 = load i32, i32* %9
%68 = mul nsw i32 %67, -1
store i32 %68, i32* %9
br label %69
69: ; preds = %66, %61
%70 = call i32 (...) @rand()
%71 = srem i32 %70, 2
store i32 %71, i32* %11
%72 = load i32, i32* %11
%73 = icmp eq i32 %72, 1
br i1 %73, label %74, label %77
74: ; preds = %69
%75 = load i32, i32* %10
%76 = mul nsw i32 %75, -1
store i32 %76, i32* %10
br label %77
77: ; preds = %74, %69
%78 = load i32*, i32** %6
%79 = load i32, i32* %8
%80 = load i32, i32* %9
%81 = load i32, i32* %10
%82 = call i32 @fprintf(i32* %78, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %79, i32 %80, i32 %81)
br label %83
83: ; preds = %77
%84 = load i32, i32* %12
%85 = add nsw i32 %84, 1
store i32 %85, i32* %12
br label %17
86: ; preds = %17
%87 = load i32*, i32** %6
%88 = call i32 @fclose(i32* %87)
ret i32 1
}

LLVM IR (-O2):
@.str = [12 x i8] c"q%d/c%d.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [10 x i8] c"%d %d %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 28, i32 1)
%6 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %2, %33
%8 = phi i32 [ 0, %2 ], [ %52, %33 ]
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 28
%11 = add nsw i32 %10, 1
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 28
%14 = icmp eq i32 %13, %10
br i1 %14, label %15, label %19
15: ; preds = %7, %15
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 28
%18 = icmp eq i32 %17, %10
br i1 %18, label %15, label %19
19: ; preds = %15, %7
%20 = phi i32 [ %13, %7 ], [ %17, %15 ]
%21 = add nsw i32 %20, 1
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 28
%24 = icmp eq i32 %23, %20
%25 = icmp eq i32 %23, %10
%26 = select i1 %24, i1 true, i1 %25
br i1 %26, label %27, label %33
27: ; preds = %19, %27
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 28
%30 = icmp eq i32 %29, %20
%31 = icmp eq i32 %29, %10
%32 = select i1 %30, i1 true, i1 %31
br i1 %32, label %27, label %33
33: ; preds = %27, %19
%34 = phi i32 [ %23, %19 ], [ %29, %27 ]
%35 = add nsw i32 %34, 1
%36 = tail call i32 (...) @rand()
%37 = srem i32 %36, 2
%38 = icmp eq i32 %37, 1
%39 = xor i32 %10, -1
%40 = select i1 %38, i32 %39, i32 %11
%41 = tail call i32 (...) @rand()
%42 = srem i32 %41, 2
%43 = icmp eq i32 %42, 1
%44 = xor i32 %20, -1
%45 = select i1 %43, i32 %44, i32 %21
%46 = tail call i32 (...) @rand()
%47 = srem i32 %46, 2
%48 = icmp eq i32 %47, 1
%49 = xor i32 %34, -1
%50 = select i1 %48, i32 %49, i32 %35
%51 = tail call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %45, i32 %50)
%52 = add nuw nsw i32 %8, 1
%53 = icmp eq i32 %52, 150
br i1 %53, label %54, label %7
54: ; preds = %33
%55 = tail call i32 @fclose(i32* %6)
ret i32 1
}