#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 opd_image {
  int dummy;
};
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
struct opd_image *opd_find_image(char const *, char const *, int /*<<< orphan*/,
                                 int /*<<< orphan*/);
struct opd_image *opd_new_image(char const *, char const *, int,
                                int /*<<< orphan*/, int /*<<< orphan*/);
struct opd_image *opd_get_image(char const *name, char const *app_name,
                                int kernel, pid_t tid, pid_t tgid) {
  struct opd_image *image;
  if ((image = opd_find_image(name, app_name, tid, tgid)) == NULL)
    image = opd_new_image(name, app_name, kernel, tid, tgid);
  return image;
}


x86 assembly (clang, -O0):
<opd_get_image>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1030 <opd_find_image@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1176 <opd_get_image+0x56>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1040 <opd_new_image@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opd_get_image>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %ecx,%edx
mov    %r8d,%ecx
call   1030 <opd_find_image@plt>
test   %rax,%rax
je     114f <opd_get_image+0x2f>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <opd_new_image@plt>

LLVM IR (-O0):
%struct.opd_image = type { i32 }
define %struct.opd_image* @opd_get_image(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.opd_image*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = load i32, i32* %9
%15 = load i32, i32* %10
%16 = call %struct.opd_image* @opd_find_image(i8* %12, i8* %13, i32 %14, i32 %15)
store %struct.opd_image* %16, %struct.opd_image** %11
%17 = icmp eq %struct.opd_image* %16, null
br i1 %17, label %18, label %25
18: ; preds = %5
%19 = load i8*, i8** %6
%20 = load i8*, i8** %7
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = load i32, i32* %10
%24 = call %struct.opd_image* @opd_new_image(i8* %19, i8* %20, i32 %21, i32 %22, i32 %23)
store %struct.opd_image* %24, %struct.opd_image** %11
br label %25
25: ; preds = %18, %5
%26 = load %struct.opd_image*, %struct.opd_image** %11
ret %struct.opd_image* %26
}

LLVM IR (-O2):
%struct.opd_image = type { i32 }
define %struct.opd_image* @opd_get_image(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call %struct.opd_image* @opd_find_image(i8* %0, i8* %1, i32 %3, i32 %4)
%7 = icmp eq %struct.opd_image* %6, null
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call %struct.opd_image* @opd_new_image(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4)
br label %10
10: ; preds = %8, %5
%11 = phi %struct.opd_image* [ %9, %8 ], [ %6, %5 ]
ret %struct.opd_image* %11
}