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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
struct profile *profile_get_from_name(char *);
struct profile *profile_new(char *);
int /*<<< orphan*/ profile_register(struct profile *);
int get_from_name(char **av) {
  struct profile *p;
  p = profile_new("banana");
  profile_register(p);
  p = profile_get_from_name(av[2]);
  if (p == NULL) {
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<get_from_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <profile_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <profile_register@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <profile_get_from_name@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1182 <get_from_name+0x52>
mov    0x2e68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    118e <get_from_name+0x5e>
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_from_name>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
call   1030 <profile_new@plt>
mov    %rax,%rdi
call   1050 <profile_register@plt>
mov    0x10(%rbx),%rdi
call   1040 <profile_get_from_name@plt>
test   %rax,%rax
jne    115f <get_from_name+0x2f>
mov    0x2e83(%rip),%rax
jmp    1166 <get_from_name+0x36>
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.profile = type { i32 }
@.str = [7 x i8] c"banana\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @get_from_name(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca %struct.profile*
store i8** %0, i8*** %3
%5 = call %struct.profile* @profile_new(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store %struct.profile* %5, %struct.profile** %4
%6 = load %struct.profile*, %struct.profile** %4
%7 = call i32 @profile_register(%struct.profile* %6)
%8 = load i8**, i8*** %3
%9 = getelementptr inbounds i8*, i8** %8, i64 2
%10 = load i8*, i8** %9
%11 = call %struct.profile* @profile_get_from_name(i8* %10)
store %struct.profile* %11, %struct.profile** %4
%12 = load %struct.profile*, %struct.profile** %4
%13 = icmp eq %struct.profile* %12, null
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %2
br label %18
16: ; preds = %1
%17 = load i32, i32* @EXIT_SUCCESS
store i32 %17, i32* %2
br label %18
18: ; preds = %16, %14
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
%struct.profile = type { i32 }
@.str = [7 x i8] c"banana\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @get_from_name(i8** nocapture %0) {
%2 = tail call %struct.profile* @profile_new(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @profile_register(%struct.profile* %2)
%4 = getelementptr inbounds i8*, i8** %0, i64 2
%5 = load i8*, i8** %4
%6 = tail call %struct.profile* @profile_get_from_name(i8* %5)
%7 = icmp eq %struct.profile* %6, null
%8 = load i32, i32* @EXIT_FAILURE
%9 = load i32, i32* @EXIT_SUCCESS
%10 = select i1 %7, i32 %8, i32 %9
ret i32 %10
}