#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 */
struct crash_info {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
int system(char *);
int show_x11(const struct crash_info *UNUSED_info __attribute__((unused)),
             const char *UNUSED_sigdesc __attribute__((unused)),
             const char *logfile) {
  char buf[512] = {'\0'};
  int ret;
  snprintf(buf, sizeof(buf),
           "xmessage -buttons \"Show log...:0,Close:1\" -center \"The "
           "application has crashed.\n\nA crash log was written to %s\"",
           logfile);
  ret = system(buf);
  if (ret == -1 || ret == 127)
    return 0;
  if (ret == 0) {
    snprintf(buf, sizeof(buf),
             "xmessage -buttons \"Okay:0\" -center -file \"%s\"", logfile);
    system(buf);
  }
  return 1;
}


x86 assembly (clang, -O0):
<show_x11>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
lea    -0x220(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x200,%esi
lea    0xe8f(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x220(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x224(%rbp)
cmpl   $0xffffffff,-0x224(%rbp)
je     11a2 <show_x11+0x72>
cmpl   $0x7f,-0x224(%rbp)
jne    11ae <show_x11+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    11ea <show_x11+0xba>
cmpl   $0x0,-0x224(%rbp)
jne    11e3 <show_x11+0xb3>
lea    -0x220(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x200,%esi
lea    0xe9e(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x220(%rbp),%rdi
call   1030 <system@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_x11>:
push   %rbp
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rdx,%r14
mov    %rsp,%rbx
xor    %ebp,%ebp
mov    $0x200,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xea7(%rip),%rdx
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r14,%rcx
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
cmp    $0xffffffff,%eax
je     11a6 <show_x11+0x76>
cmp    $0x7f,%eax
je     11a6 <show_x11+0x76>
test   %eax,%eax
jne    11a1 <show_x11+0x71>
lea    0xeea(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r14,%rcx
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.crash_info = type { i32 }
@.str = [112 x i8] c"xmessage -buttons \22Show log...:0,Close:1\22 -center \22The application has crashed.\0A\0AA crash log was written to %s\22\00"
@.str.1 = [46 x i8] c"xmessage -buttons \22Okay:0\22 -center -file \22%s\22\00"
define i32 @show_x11(%struct.crash_info* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.crash_info*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [512 x i8]
%9 = alloca i32
store %struct.crash_info* %0, %struct.crash_info** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = bitcast [512 x i8]* %8 to i8*
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%12 = load i8*, i8** %7
%13 = call i32 @snprintf(i8* %11, i32 512, i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%15 = call i32 @system(i8* %14)
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = icmp eq i32 %16, -1
br i1 %17, label %21, label %18
18: ; preds = %3
%19 = load i32, i32* %9
%20 = icmp eq i32 %19, 127
br i1 %20, label %21, label %22
21: ; preds = %18, %3
store i32 0, i32* %4
br label %32
22: ; preds = %18
%23 = load i32, i32* %9
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%27 = load i8*, i8** %7
%28 = call i32 @snprintf(i8* %26, i32 512, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%30 = call i32 @system(i8* %29)
br label %31
31: ; preds = %25, %22
store i32 1, i32* %4
br label %32
32: ; preds = %31, %21
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
%struct.crash_info = type { i32 }
@.str = [112 x i8] c"xmessage -buttons \22Show log...:0,Close:1\22 -center \22The application has crashed.\0A\0AA crash log was written to %s\22\00"
@.str.1 = [46 x i8] c"xmessage -buttons \22Okay:0\22 -center -file \22%s\22\00"
define i32 @show_x11(%struct.crash_info* nocapture readnone %0, i8* nocapture readnone %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 512, i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = call i32 @system(i8* %5)
switch i32 %7, label %11 [
i32 -1, label %12
i32 127, label %12
i32 0, label %8
]
8: ; preds = %3
%9 = call i32 @snprintf(i8* %5, i32 512, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = call i32 @system(i8* %5)
br label %11
11: ; preds = %3, %8
br label %12
12: ; preds = %3, %3, %11
%13 = phi i32 [ 1, %11 ], [ 0, %3 ], [ 0, %3 ]
ret i32 %13
}