#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 */
double RAND_MAX;
int /*<<< orphan*/ printf(char *, int, ...);
double random();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int i, j, n = 10, g;
  double p = 0.1;
  srand(time(NULL));
  for (i = 0; i < n; i++) {
    printf("hn %d\nns\n", i);
    for (j = 0; j < n; j++)
      if (random() < p * RAND_MAX)
        printf("hn %d\nhe %d %d\nns\n", i, i, j);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x10(%rbp)
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    120b <main+0xcb>
mov    -0x8(%rbp),%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f8 <main+0xb8>
mov    $0x0,%al
call   1060 <random@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mov    0x2e28(%rip),%rax
mulsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    11e5 <main+0xa5>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <main+0xaa>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119e <main+0x5e>
jmp    11fd <main+0xbd>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117a <main+0x3a>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xeac(%rip),%r14
mov    0x2e85(%rip),%rbx
lea    0xea8(%rip),%r15
xor    %ebp,%ebp
jmp    117c <main+0x3c>
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0xa,%ebp
je     134a <main+0x20a>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <random@plt>
movsd  (%rbx),%xmm1
movsd  0xe65(%rip),%xmm2
mulsd  %xmm2,%xmm1
ucomisd %xmm0,%xmm1
jbe    11b5 <main+0x75>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <random@plt>
movsd  (%rbx),%xmm1
mulsd  0xe38(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11e1 <main+0xa1>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    $0x1,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <random@plt>
movsd  (%rbx),%xmm1
mulsd  0xe0c(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    120d <main+0xcd>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    $0x2,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <random@plt>
movsd  (%rbx),%xmm1
mulsd  0xde0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1239 <main+0xf9>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    $0x3,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <random@plt>
movsd  (%rbx),%xmm1
mulsd  0xdb4(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1265 <main+0x125>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    $0x4,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <random@plt>
movsd  (%rbx),%xmm1
mulsd  0xd88(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1291 <main+0x151>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    $0x5,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <random@plt>
movsd  (%rbx),%xmm1
mulsd  0xd5c(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    12bd <main+0x17d>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    $0x6,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <random@plt>
movsd  (%rbx),%xmm1
mulsd  0xd30(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    12e9 <main+0x1a9>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    $0x7,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <random@plt>
movsd  (%rbx),%xmm1
mulsd  0xd04(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1315 <main+0x1d5>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    $0x8,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <random@plt>
movsd  (%rbx),%xmm1
mulsd  0xcd8(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1170 <main+0x30>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    $0x9,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1170 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"hn %d\0Ans\0A\00"
@RAND_MAX = global double 0.000000e+00
@.str.1 = [19 x i8] c"hn %d\0Ahe %d %d\0Ans\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store i32 0, i32* %1
store i32 10, i32* %4
store double 1.000000e-01, double* %6
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
store i32 0, i32* %2
br label %9
9: ; preds = %36, %0
%10 = load i32, i32* %2
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %39
13: ; preds = %9
%14 = load i32, i32* %2
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 0, i32* %3
br label %16
16: ; preds = %32, %13
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %35
20: ; preds = %16
%21 = call double (...) @random()
%22 = load double, double* %6
%23 = load double, double* @RAND_MAX
%24 = fmul double %22, %23
%25 = fcmp olt double %21, %24
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = load i32, i32* %2
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
br label %31
31: ; preds = %26, %20
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %16
35: ; preds = %16
br label %36
36: ; preds = %35
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
br label %9
39: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"hn %d\0Ans\0A\00"
@RAND_MAX = global double 0.000000e+00
@.str.1 = [19 x i8] c"hn %d\0Ahe %d %d\0Ans\0A\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %0, %75
%4 = phi i32 [ 0, %0 ], [ %76, %75 ]
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call double (...) @random()
%7 = load double, double* @RAND_MAX
%8 = fmul double %7, 1.000000e-01
%9 = fcmp olt double %6, %8
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4, i32 0)
br label %12
12: ; preds = %3, %10
%13 = tail call double (...) @random()
%14 = load double, double* @RAND_MAX
%15 = fmul double %14, 1.000000e-01
%16 = fcmp olt double %13, %15
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4, i32 1)
br label %19
19: ; preds = %17, %12
%20 = tail call double (...) @random()
%21 = load double, double* @RAND_MAX
%22 = fmul double %21, 1.000000e-01
%23 = fcmp olt double %20, %22
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4, i32 2)
br label %26
26: ; preds = %24, %19
%27 = tail call double (...) @random()
%28 = load double, double* @RAND_MAX
%29 = fmul double %28, 1.000000e-01
%30 = fcmp olt double %27, %29
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4, i32 3)
br label %33
33: ; preds = %31, %26
%34 = tail call double (...) @random()
%35 = load double, double* @RAND_MAX
%36 = fmul double %35, 1.000000e-01
%37 = fcmp olt double %34, %36
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4, i32 4)
br label %40
40: ; preds = %38, %33
%41 = tail call double (...) @random()
%42 = load double, double* @RAND_MAX
%43 = fmul double %42, 1.000000e-01
%44 = fcmp olt double %41, %43
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4, i32 5)
br label %47
47: ; preds = %45, %40
%48 = tail call double (...) @random()
%49 = load double, double* @RAND_MAX
%50 = fmul double %49, 1.000000e-01
%51 = fcmp olt double %48, %50
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4, i32 6)
br label %54
54: ; preds = %52, %47
%55 = tail call double (...) @random()
%56 = load double, double* @RAND_MAX
%57 = fmul double %56, 1.000000e-01
%58 = fcmp olt double %55, %57
br i1 %58, label %59, label %61
59: ; preds = %54
%60 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4, i32 7)
br label %61
61: ; preds = %59, %54
%62 = tail call double (...) @random()
%63 = load double, double* @RAND_MAX
%64 = fmul double %63, 1.000000e-01
%65 = fcmp olt double %62, %64
br i1 %65, label %66, label %68
66: ; preds = %61
%67 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4, i32 8)
br label %68
68: ; preds = %66, %61
%69 = tail call double (...) @random()
%70 = load double, double* @RAND_MAX
%71 = fmul double %70, 1.000000e-01
%72 = fcmp olt double %69, %71
br i1 %72, label %73, label %75
73: ; preds = %68
%74 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4, i32 9)
br label %75
75: ; preds = %73, %68
%76 = add nuw nsw i32 %4, 1
%77 = icmp eq i32 %76, 10
br i1 %77, label %78, label %3
78: ; preds = %75
ret i32 0
}