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

/* Variables and functions */
int /*<<< orphan*/ add_chanrec(struct userrec *, char *);
int /*<<< orphan*/ get_chanrec(struct userrec *, char *);
struct userrec *get_user_by_handle(struct userrec *, char *);
void add_chanrec_by_handle(struct userrec *bu, char *hand, char *chname) {
  struct userrec *u;
  u = get_user_by_handle(bu, hand);
  if (!u)
    return;
  if (!get_chanrec(u, chname))
    add_chanrec(u, chname);
}


x86 assembly (clang, -O0):
<add_chanrec_by_handle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <get_user_by_handle@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1165 <add_chanrec_by_handle+0x35>
jmp    1188 <add_chanrec_by_handle+0x58>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <get_chanrec@plt>
cmp    $0x0,%eax
jne    1188 <add_chanrec_by_handle+0x58>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <add_chanrec@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_chanrec_by_handle>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
call   1040 <get_user_by_handle@plt>
test   %rax,%rax
je     1153 <add_chanrec_by_handle+0x23>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <get_chanrec@plt>
test   %eax,%eax
je     115b <add_chanrec_by_handle+0x2b>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <add_chanrec@plt>

LLVM IR (-O0):
%struct.userrec = type { i32 }
define void @add_chanrec_by_handle(%struct.userrec* %0, i8* %1, i8* %2) {
%4 = alloca %struct.userrec*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.userrec*
store %struct.userrec* %0, %struct.userrec** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load %struct.userrec*, %struct.userrec** %4
%9 = load i8*, i8** %5
%10 = call %struct.userrec* @get_user_by_handle(%struct.userrec* %8, i8* %9)
store %struct.userrec* %10, %struct.userrec** %7
%11 = load %struct.userrec*, %struct.userrec** %7
%12 = icmp ne %struct.userrec* %11, null
br i1 %12, label %14, label %13
13: ; preds = %3
br label %23
14: ; preds = %3
%15 = load %struct.userrec*, %struct.userrec** %7
%16 = load i8*, i8** %6
%17 = call i32 @get_chanrec(%struct.userrec* %15, i8* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %14
%20 = load %struct.userrec*, %struct.userrec** %7
%21 = load i8*, i8** %6
%22 = call i32 @add_chanrec(%struct.userrec* %20, i8* %21)
br label %23
23: ; preds = %13, %19, %14
ret void
}

LLVM IR (-O2):
%struct.userrec = type { i32 }
define void @add_chanrec_by_handle(%struct.userrec* %0, i8* %1, i8* %2) {
%4 = tail call %struct.userrec* @get_user_by_handle(%struct.userrec* %0, i8* %1)
%5 = icmp eq %struct.userrec* %4, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i32 @get_chanrec(%struct.userrec* %4, i8* %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @add_chanrec(%struct.userrec* %4, i8* %2)
br label %11
11: ; preds = %6, %9, %3
ret void
}