#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*/ mtrace();
int /*<<< orphan*/ printf(char *, ...);
char *re_comp(char *);
int /*<<< orphan*/ re_exec(char *);
int main(void) {
  const char *err;
  size_t i;
  int ret = 0;
  mtrace();
  for (i = 0; i < 100; ++i) {
    err = re_comp("a t.st");
    if (err) {
      printf("re_comp failed: %s\n", err);
      ret = 1;
    }
    if (!re_exec("This is a test.")) {
      printf("re_exec failed\n");
      ret = 1;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1060 <mtrace@plt>
movq   $0x0,-0x18(%rbp)
cmpq   $0x64,-0x18(%rbp)
jae    11e4 <main+0xa4>
lea    0xe89(%rip),%rdi
call   1040 <re_comp@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a4 <main+0x64>
mov    -0x10(%rbp),%rsi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x1c(%rbp)
lea    0xe70(%rip),%rdi
call   1030 <re_exec@plt>
cmp    $0x0,%eax
jne    11ce <main+0x8e>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    11d3 <main+0x93>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1165 <main+0x25>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <mtrace@plt>
mov    $0x64,%ebx
lea    0xe92(%rip),%r14
lea    0xea6(%rip),%r13
lea    0xeaf(%rip),%r15
lea    0xe84(%rip),%r12
xor    %ebp,%ebp
jmp    1196 <main+0x46>
nopw   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rbx
je     11d0 <main+0x80>
mov    %r14,%rdi
call   1050 <re_comp@plt>
test   %rax,%rax
je     11b5 <main+0x65>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ebp
mov    %r13,%rdi
call   1040 <re_exec@plt>
test   %eax,%eax
jne    1190 <main+0x40>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
jmp    1190 <main+0x40>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"a t.st\00"
@.str.1 = [20 x i8] c"re_comp failed: %s\0A\00"
@.str.2 = [16 x i8] c"This is a test.\00"
@.str.3 = [16 x i8] c"re_exec failed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (...) @mtrace()
store i64 0, i64* %3
br label %6
6: ; preds = %22, %0
%7 = load i64, i64* %3
%8 = icmp ult i64 %7, 100
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = call i8* @re_comp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %2
%11 = load i8*, i8** %2
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i8*, i8** %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 1, i32* %4
br label %16
16: ; preds = %13, %9
%17 = call i32 @re_exec(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %4
br label %21
21: ; preds = %19, %16
br label %22
22: ; preds = %21
%23 = load i64, i64* %3
%24 = add i64 %23, 1
store i64 %24, i64* %3
br label %6
25: ; preds = %6
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@.str = [7 x i8] c"a t.st\00"
@.str.1 = [20 x i8] c"re_comp failed: %s\0A\00"
@.str.2 = [16 x i8] c"This is a test.\00"
@str = [15 x i8] c"re_exec failed\00"
define i32 @main() {
%1 = tail call i32 (...) @mtrace()
br label %2
2: ; preds = %0, %15
%3 = phi i32 [ 0, %0 ], [ %16, %15 ]
%4 = phi i64 [ 0, %0 ], [ %17, %15 ]
%5 = tail call i8* @re_comp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %9
9: ; preds = %7, %2
%10 = phi i32 [ 1, %7 ], [ %3, %2 ]
%11 = tail call i32 @re_exec(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %9, %13
%16 = phi i32 [ %10, %9 ], [ 1, %13 ]
%17 = add nuw nsw i64 %4, 1
%18 = icmp eq i64 %17, 100
br i1 %18, label %19, label %2
19: ; preds = %15
ret i32 %16
}