#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*/ regex_t;
typedef int /*<<< orphan*/ popup_buffer;

/* Variables and functions */
char *convert_regexp_error(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ error_popup(char *, int, char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ myfree(char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
void regexp_error_popup(int rc, regex_t *pre) {
  char popup_buffer[4096] = {0};
  char *error = convert_regexp_error(rc, pre);
  if (error) {
    int len = strlen(popup_buffer);
    if (strlen(error) > 58) {
      memcpy(&popup_buffer[len], error, 58);
      len += 58;
      popup_buffer[len++] = '\n';
      strncat(popup_buffer, &error[58],
              ((1) > (sizeof(popup_buffer) - len)
                   ? (1)
                   : (sizeof(popup_buffer) - len)));
      popup_buffer[sizeof(popup_buffer) - 1] = 0x00;
    } else {
      strncat(popup_buffer, error,
              sizeof(popup_buffer) - strlen(popup_buffer) - 1);
    }
    myfree(error);
  }
  error_popup("regexp_error_popup: failed to compile regular expression!", 2400,
              popup_buffer);
}


x86 assembly (clang, -O0):
<regexp_error_popup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <convert_regexp_error@plt>
mov    %rax,-0x1018(%rbp)
cmpq   $0x0,-0x1018(%rbp)
je     130a <regexp_error_popup+0x19a>
lea    -0x1010(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x101c(%rbp)
mov    -0x1018(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x3a,%eax
jle    12b2 <regexp_error_popup+0x142>
movslq -0x101c(%rbp),%rax
lea    -0x1010(%rbp),%rdi
add    %rax,%rdi
mov    -0x1018(%rbp),%rsi
mov    $0x3a,%edx
call   1070 <memcpy@plt>
mov    -0x101c(%rbp),%eax
add    $0x3a,%eax
mov    %eax,-0x101c(%rbp)
mov    -0x101c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x101c(%rbp)
cltq
movb   $0xa,-0x1010(%rbp,%rax,1)
0a
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1030(%rbp)
mov    -0x1018(%rbp),%rax
add    $0x3a,%rax
mov    %rax,-0x1028(%rbp)
movslq -0x101c(%rbp),%rax
mov    $0x1000,%ecx
sub    %rax,%rcx
mov    $0x1,%eax
cmp    %rcx,%rax
jbe    1277 <regexp_error_popup+0x107>
mov    $0x1,%eax
mov    %rax,-0x1038(%rbp)
jmp    128d <regexp_error_popup+0x11d>
movslq -0x101c(%rbp),%rcx
mov    $0x1000,%eax
sub    %rcx,%rax
mov    %rax,-0x1038(%rbp)
mov    -0x1028(%rbp),%rsi
mov    -0x1030(%rbp),%rdi
mov    -0x1038(%rbp),%rax
mov    %eax,%edx
call   1060 <strncat@plt>
movb   $0x0,-0x11(%rbp)
jmp    12fe <regexp_error_popup+0x18e>
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1048(%rbp)
mov    -0x1018(%rbp),%rax
mov    %rax,-0x1040(%rbp)
lea    -0x1010(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1048(%rbp),%rdi
mov    -0x1040(%rbp),%rsi
movslq %eax,%rcx
mov    $0x1000,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
call   1060 <strncat@plt>
mov    -0x1018(%rbp),%rdi
call   1090 <myfree@plt>
lea    -0x1010(%rbp),%rdx
lea    0xce8(%rip),%rdi
mov    $0x960,%esi
call   1080 <error_popup@plt>
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<regexp_error_popup>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsp,%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <convert_regexp_error@plt>
test   %rax,%rax
je     122f <regexp_error_popup+0xbf>
mov    %rax,%rbx
mov    %rsp,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x3b,%eax
jl     120a <regexp_error_popup+0x9a>
lea    -0xfc5(%r14),%eax
neg    %eax
cmp    $0xfc5,%r14d
movslq %r14d,%r14
lea    (%rsp,%r14,1),%rdi
mov    $0x1,%ebp
cmovne %eax,%ebp
mov    %rbx,%rsi
mov    $0x3a,%edx
call   1070 <memcpy@plt>
movb   $0xa,0x3a(%rsp,%r14,1)
mov    %rbx,%rsi
add    $0x3a,%rsi
mov    %rsp,%rdi
mov    %ebp,%edx
call   1060 <strncat@plt>
movb   $0x0,0xfff(%rsp)
jmp    1227 <regexp_error_popup+0xb7>
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    $0xfff,%edx
sub    %eax,%edx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <strncat@plt>
mov    %rbx,%rdi
call   1090 <myfree@plt>
lea    0xdca(%rip),%rdi
mov    %rsp,%rdx
mov    $0x960,%esi
call   1080 <error_popup@plt>
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [58 x i8] c"regexp_error_popup: failed to compile regular expression!\00"
define void @regexp_error_popup(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca [4096 x i8]
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%8 = bitcast [4096 x i8]* %5 to i8*
%9 = load i32, i32* %3
%10 = load i32*, i32** %4
%11 = call i8* @convert_regexp_error(i32 %9, i32* %10)
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %62
14: ; preds = %2
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %7
%17 = load i8*, i8** %6
%18 = call i32 @strlen(i8* %17)
%19 = icmp sgt i32 %18, 58
br i1 %19, label %20, label %49
20: ; preds = %14
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 %22
%24 = load i8*, i8** %6
%25 = call i32 @memcpy(i8* %23, i8* %24, i32 58)
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 58
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 %30
store i8 10, i8* %31
%32 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 58
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = sub i64 4096, %36
%38 = icmp ugt i64 1, %37
br i1 %38, label %39, label %40
39: ; preds = %20
br label %44
40: ; preds = %20
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = sub i64 4096, %42
br label %44
44: ; preds = %40, %39
%45 = phi i64 [ 1, %39 ], [ %43, %40 ]
%46 = trunc i64 %45 to i32
%47 = call i32 @strncat(i8* %32, i8* %34, i32 %46)
%48 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 4095
store i8 0, i8* %48
br label %59
49: ; preds = %14
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%51 = load i8*, i8** %6
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%53 = call i32 @strlen(i8* %52)
%54 = sext i32 %53 to i64
%55 = sub i64 4096, %54
%56 = sub i64 %55, 1
%57 = trunc i64 %56 to i32
%58 = call i32 @strncat(i8* %50, i8* %51, i32 %57)
br label %59
59: ; preds = %49, %44
%60 = load i8*, i8** %6
%61 = call i32 @myfree(i8* %60)
br label %62
62: ; preds = %59, %2
%63 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%64 = call i32 @error_popup(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 2400, i8* %63)
ret void
}

LLVM IR (-O2):
@.str = [58 x i8] c"regexp_error_popup: failed to compile regular expression!\00"
define void @regexp_error_popup(i32 %0, i32* %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = tail call i8* @convert_regexp_error(i32 %0, i32* %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %30, label %7
7: ; preds = %2
%8 = call i32 @strlen(i8* %4)
%9 = call i32 @strlen(i8* %5)
%10 = icmp sgt i32 %9, 58
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = sext i32 %8 to i64
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %12
%14 = call i32 @memcpy(i8* %13, i8* %5, i32 58)
%15 = add nsw i32 %8, 58
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %16
store i8 10, i8* %17
%18 = getelementptr inbounds i8, i8* %5, i64 58
%19 = sub i32 4037, %8
%20 = icmp eq i32 %8, 4037
%21 = select i1 %20, i32 1, i32 %19
%22 = call i32 @strncat(i8* %4, i8* %18, i32 %21)
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 4095
store i8 0, i8* %23
br label %28
24: ; preds = %7
%25 = call i32 @strlen(i8* %4)
%26 = sub i32 4095, %25
%27 = call i32 @strncat(i8* %4, i8* %5, i32 %26)
br label %28
28: ; preds = %24, %11
%29 = call i32 @myfree(i8* %5)
br label %30
30: ; preds = %28, %2
%31 = call i32 @error_popup(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 2400, i8* %4)
ret void
}