#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*/ printf(char *, ...);
char *re_comp(char *);
int /*<<< orphan*/ re_exec(char *);
int main(void) {
  const char *err;
  size_t i;
  int ret = 0;
  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)
movq   $0x0,-0x18(%rbp)
cmpq   $0x64,-0x18(%rbp)
jae    11cd <main+0x9d>
lea    0xea0(%rip),%rdi
call   1040 <re_comp@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118d <main+0x5d>
mov    -0x10(%rbp),%rsi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x1c(%rbp)
lea    0xe87(%rip),%rdi
call   1030 <re_exec@plt>
cmp    $0x0,%eax
jne    11b7 <main+0x87>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    11bc <main+0x8c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114e <main+0x1e>
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
mov    $0x64,%ebx
lea    0xea9(%rip),%r14
lea    0xebd(%rip),%r13
lea    0xec6(%rip),%r15
lea    0xe9b(%rip),%r12
xor    %ebp,%ebp
jmp    1176 <main+0x36>
add    $0xffffffffffffffff,%rbx
je     11b0 <main+0x70>
mov    %r14,%rdi
call   1050 <re_comp@plt>
test   %rax,%rax
je     1195 <main+0x55>
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    1170 <main+0x30>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
jmp    1170 <main+0x30>
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
store i64 0, i64* %3
br label %5
5: ; preds = %21, %0
%6 = load i64, i64* %3
%7 = icmp ult i64 %6, 100
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = call i8* @re_comp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %2
%10 = load i8*, i8** %2
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i8*, i8** %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %13)
store i32 1, i32* %4
br label %15
15: ; preds = %12, %8
%16 = call i32 @re_exec(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = 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 %20
20: ; preds = %18, %15
br label %21
21: ; preds = %20
%22 = load i64, i64* %3
%23 = add i64 %22, 1
store i64 %23, i64* %3
br label %5
24: ; preds = %5
%25 = load i32, i32* %4
ret i32 %25
}

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() {
br label %1
1: ; preds = %0, %14
%2 = phi i32 [ 0, %0 ], [ %15, %14 ]
%3 = phi i64 [ 0, %0 ], [ %16, %14 ]
%4 = tail call i8* @re_comp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %8
8: ; preds = %6, %1
%9 = phi i32 [ 1, %6 ], [ %2, %1 ]
%10 = tail call i32 @re_exec(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %8, %12
%15 = phi i32 [ %9, %8 ], [ 1, %12 ]
%16 = add nuw nsw i64 %3, 1
%17 = icmp eq i64 %16, 100
br i1 %17, label %18, label %1
18: ; preds = %14
ret i32 %15
}