#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 */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ test_popen();
int main(int argc, const char *argv[]) {
  unsigned i;
  for (i = 0; i < 30; i++) {
    printf("Round %u\n", i);
    if (test_popen() != 0) {
      printf("FAIL\n");
      exit(0);
    }
  }
  printf("popen OK\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1e,-0x14(%rbp)
jae    11a1 <main+0x71>
mov    -0x14(%rbp),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <test_popen@plt>
cmp    $0x0,%rax
je     118e <main+0x5e>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    1193 <main+0x63>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <test_popen@plt>
test   %rax,%rax
jne    1185 <main+0x45>
add    $0x1,%ebp
cmp    $0x1e,%ebp
jne    1150 <main+0x10>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"Round %u\0A\00"
@.str.1 = [6 x i8] c"FAIL\0A\00"
@.str.2 = [10 x i8] c"popen OK\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %7
7: ; preds = %19, %2
%8 = load i32, i32* %6
%9 = icmp ult i32 %8, 30
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = load i32, i32* %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i64 (...) @test_popen()
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %10
br label %19
19: ; preds = %18
%20 = load i32, i32* %6
%21 = add i32 %20, 1
store i32 %21, i32* %6
br label %7
22: ; preds = %7
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"Round %u\0A\00"
@str = [9 x i8] c"popen OK\00"
@str.3 = [5 x i8] c"FAIL\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %6
3: ; preds = %6
%4 = add nuw nsw i32 %7, 1
%5 = icmp eq i32 %4, 30
br i1 %5, label %14, label %6
6: ; preds = %2, %3
%7 = phi i32 [ 0, %2 ], [ %4, %3 ]
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i64 (...) @test_popen()
%10 = icmp eq i64 %9, 0
br i1 %10, label %3, label %11
11: ; preds = %6
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.3, i64 0, i64 0))
%13 = tail call i32 @exit(i32 0)
unreachable
14: ; preds = %3
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
ret i32 0
}