#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 if_entry {
  int dummy;
};

/* Variables and functions */
int if_add_warning(struct if_entry *, char *, char const *);
int err_msg(int err, const char *type, struct if_entry *entry,
            struct if_entry *check) {
  if (err > 0)
    return err;
  if (err < 0)
    return if_add_warning(entry, "has a %s but failed to find it reliably",
                          type);
  if (!check)
    return if_add_warning(entry, "has a %s but failed to find it", type);
  return 0;
}


x86 assembly (clang, -O0):
<err_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    113c <err_msg+0x2c>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1190 <err_msg+0x80>
cmpl   $0x0,-0x8(%rbp)
jge    1162 <err_msg+0x52>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeab(%rip),%rsi
call   1030 <if_add_warning@plt>
mov    %eax,-0x4(%rbp)
jmp    1190 <err_msg+0x80>
cmpq   $0x0,-0x20(%rbp)
jne    1189 <err_msg+0x79>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeac(%rip),%rsi
call   1030 <if_add_warning@plt>
mov    %eax,-0x4(%rbp)
jmp    1190 <err_msg+0x80>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<err_msg>:
test   %edi,%edi
jle    1117 <err_msg+0x7>
mov    %edi,%eax
ret
mov    %rsi,%rax
js     112c <err_msg+0x1c>
xor    %edi,%edi
test   %rcx,%rcx
jne    1114 <err_msg+0x4>
lea    0xefe(%rip),%rsi
jmp    1133 <err_msg+0x23>
lea    0xecd(%rip),%rsi
mov    %rdx,%rdi
mov    %rax,%rdx
jmp    1030 <if_add_warning@plt>

LLVM IR (-O0):
%struct.if_entry = type { i32 }
@.str = [40 x i8] c"has a %s but failed to find it reliably\00"
@.str.1 = [31 x i8] c"has a %s but failed to find it\00"
define i32 @err_msg(i32 %0, i8* %1, %struct.if_entry* %2, %struct.if_entry* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca %struct.if_entry*
%9 = alloca %struct.if_entry*
store i32 %0, i32* %6
store i8* %1, i8** %7
store %struct.if_entry* %2, %struct.if_entry** %8
store %struct.if_entry* %3, %struct.if_entry** %9
%10 = load i32, i32* %6
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = load i32, i32* %6
store i32 %13, i32* %5
br label %29
14: ; preds = %4
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load %struct.if_entry*, %struct.if_entry** %8
%19 = load i8*, i8** %7
%20 = call i32 @if_add_warning(%struct.if_entry* %18, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %19)
store i32 %20, i32* %5
br label %29
21: ; preds = %14
%22 = load %struct.if_entry*, %struct.if_entry** %9
%23 = icmp ne %struct.if_entry* %22, null
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = load %struct.if_entry*, %struct.if_entry** %8
%26 = load i8*, i8** %7
%27 = call i32 @if_add_warning(%struct.if_entry* %25, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %26)
store i32 %27, i32* %5
br label %29
28: ; preds = %21
store i32 0, i32* %5
br label %29
29: ; preds = %28, %24, %17, %12
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
%struct.if_entry = type { i32 }
@.str = [40 x i8] c"has a %s but failed to find it reliably\00"
@.str.1 = [31 x i8] c"has a %s but failed to find it\00"
define i32 @err_msg(i32 %0, i8* %1, %struct.if_entry* %2, %struct.if_entry* readnone %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %13, label %6
6: ; preds = %4
%7 = icmp slt i32 %0, 0
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = icmp eq %struct.if_entry* %3, null
br i1 %9, label %10, label %13
10: ; preds = %8, %6
%11 = phi i8* [ getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), %6 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), %8 ]
%12 = tail call i32 @if_add_warning(%struct.if_entry* %2, i8* %11, i8* %1)
br label %13
13: ; preds = %10, %8, %4
%14 = phi i32 [ %0, %4 ], [ 0, %8 ], [ %12, %10 ]
ret i32 %14
}