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

/* Variables and functions */
struct t_gui_buffer *gui_buffer_search_by_full_name(char const *);
struct t_gui_buffer *gui_buffer_search_by_number(long);
struct t_gui_buffer *gui_buffer_search_by_partial_name(int /*<<< orphan*/ *,
                                                       char const *);
long strtol(char const *, char **, int);
struct t_gui_buffer *gui_buffer_search_by_number_or_name(const char *string) {
  struct t_gui_buffer *ptr_buffer;
  long number;
  char *error;
  ptr_buffer = NULL;
  number = strtol(string, &error, 10);
  if (error && !error[0])
    ptr_buffer = gui_buffer_search_by_number(number);
  else {
    ptr_buffer = gui_buffer_search_by_full_name(string);
    if (!ptr_buffer)
      ptr_buffer = gui_buffer_search_by_partial_name(NULL, string);
  }
  return ptr_buffer;
}


x86 assembly (clang, -O0):
<gui_buffer_search_by_number_or_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1194 <gui_buffer_search_by_number_or_name+0x54>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1194 <gui_buffer_search_by_number_or_name+0x54>
mov    -0x18(%rbp),%rdi
call   1040 <gui_buffer_search_by_number@plt>
mov    %rax,-0x10(%rbp)
jmp    11c2 <gui_buffer_search_by_number_or_name+0x82>
mov    -0x8(%rbp),%rdi
call   1030 <gui_buffer_search_by_full_name@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11bd <gui_buffer_search_by_number_or_name+0x7d>
mov    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <gui_buffer_search_by_partial_name@plt>
mov    %rax,-0x10(%rbp)
jmp    11c2 <gui_buffer_search_by_number_or_name+0x82>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_buffer_search_by_number_or_name>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
je     1166 <gui_buffer_search_by_number_or_name+0x26>
cmpb   $0x0,(%rcx)
je     1188 <gui_buffer_search_by_number_or_name+0x48>
mov    %rbx,%rdi
call   1030 <gui_buffer_search_by_full_name@plt>
test   %rax,%rax
je     1179 <gui_buffer_search_by_number_or_name+0x39>
add    $0x10,%rsp
pop    %rbx
ret
xor    %edi,%edi
mov    %rbx,%rsi
add    $0x10,%rsp
pop    %rbx
jmp    1060 <gui_buffer_search_by_partial_name@plt>
mov    %rax,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <gui_buffer_search_by_number@plt>

LLVM IR (-O0):
%struct.t_gui_buffer = type { i32 }
define %struct.t_gui_buffer* @gui_buffer_search_by_number_or_name(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.t_gui_buffer*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %2
store %struct.t_gui_buffer* null, %struct.t_gui_buffer** %3
%6 = load i8*, i8** %2
%7 = call i64 @strtol(i8* %6, i8** %5, i32 10)
store i64 %7, i64* %4
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %18
10: ; preds = %1
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = load i64, i64* %4
%17 = call %struct.t_gui_buffer* @gui_buffer_search_by_number(i64 %16)
store %struct.t_gui_buffer* %17, %struct.t_gui_buffer** %3
br label %27
18: ; preds = %10, %1
%19 = load i8*, i8** %2
%20 = call %struct.t_gui_buffer* @gui_buffer_search_by_full_name(i8* %19)
store %struct.t_gui_buffer* %20, %struct.t_gui_buffer** %3
%21 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %3
%22 = icmp ne %struct.t_gui_buffer* %21, null
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = load i8*, i8** %2
%25 = call %struct.t_gui_buffer* @gui_buffer_search_by_partial_name(i32* null, i8* %24)
store %struct.t_gui_buffer* %25, %struct.t_gui_buffer** %3
br label %26
26: ; preds = %23, %18
br label %27
27: ; preds = %26, %15
%28 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %3
ret %struct.t_gui_buffer* %28
}

LLVM IR (-O2):
%struct.t_gui_buffer = type { i32 }
define %struct.t_gui_buffer* @gui_buffer_search_by_number_or_name(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i64 @strtol(i8* %0, i8** %2, i32 10)
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %1
%8 = load i8, i8* %5
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call %struct.t_gui_buffer* @gui_buffer_search_by_number(i64 %4)
br label %17
12: ; preds = %7, %1
%13 = tail call %struct.t_gui_buffer* @gui_buffer_search_by_full_name(i8* %0)
%14 = icmp eq %struct.t_gui_buffer* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call %struct.t_gui_buffer* @gui_buffer_search_by_partial_name(i32* null, i8* %0)
br label %17
17: ; preds = %12, %15, %10
%18 = phi %struct.t_gui_buffer* [ %13, %12 ], [ %16, %15 ], [ %11, %10 ]
ret %struct.t_gui_buffer* %18
}