#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 */
typedef void lobject;
struct lemon {
  int dummy;
};

/* Variables and functions */
void *linteger_create_object_from_long(struct lemon *, long);
long linteger_to_long(struct lemon *, void *);
scalar_t__ lobject_is_pointer(struct lemon *, void *);
void *linteger_create_object_from_integer(struct lemon *lemon,
                                          struct lobject *integer) {
  long value;
  if (lobject_is_pointer(lemon, integer)) {
    return integer;
  }
  value = linteger_to_long(lemon, integer);
  return linteger_create_object_from_long(lemon, value);
}


x86 assembly (clang, -O0):
<linteger_create_object_from_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <lobject_is_pointer@plt>
cmp    $0x0,%rax
je     1164 <linteger_create_object_from_integer+0x34>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1186 <linteger_create_object_from_integer+0x56>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <linteger_to_long@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <linteger_create_object_from_long@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linteger_create_object_from_integer>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <lobject_is_pointer@plt>
test   %rax,%rax
je     114f <linteger_create_object_from_integer+0x1f>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <linteger_to_long@plt>
mov    %r14,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <linteger_create_object_from_long@plt>

LLVM IR (-O0):
%struct.lemon = type { i32 }
%struct.lobject = type opaque
define i8* @linteger_create_object_from_integer(%struct.lemon* %0, %struct.lobject* %1) {
%3 = alloca i8*
%4 = alloca %struct.lemon*
%5 = alloca %struct.lobject*
%6 = alloca i64
store %struct.lemon* %0, %struct.lemon** %4
store %struct.lobject* %1, %struct.lobject** %5
%7 = load %struct.lemon*, %struct.lemon** %4
%8 = load %struct.lobject*, %struct.lobject** %5
%9 = bitcast %struct.lobject* %8 to i8*
%10 = call i64 @lobject_is_pointer(%struct.lemon* %7, i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load %struct.lobject*, %struct.lobject** %5
%14 = bitcast %struct.lobject* %13 to i8*
store i8* %14, i8** %3
br label %23
15: ; preds = %2
%16 = load %struct.lemon*, %struct.lemon** %4
%17 = load %struct.lobject*, %struct.lobject** %5
%18 = bitcast %struct.lobject* %17 to i8*
%19 = call i64 @linteger_to_long(%struct.lemon* %16, i8* %18)
store i64 %19, i64* %6
%20 = load %struct.lemon*, %struct.lemon** %4
%21 = load i64, i64* %6
%22 = call i8* @linteger_create_object_from_long(%struct.lemon* %20, i64 %21)
store i8* %22, i8** %3
br label %23
23: ; preds = %15, %12
%24 = load i8*, i8** %3
ret i8* %24
}

LLVM IR (-O2):
%struct.lemon = type { i32 }
%struct.lobject = type opaque
define i8* @linteger_create_object_from_integer(%struct.lemon* %0, %struct.lobject* %1) {
%3 = bitcast %struct.lobject* %1 to i8*
%4 = tail call i64 @lobject_is_pointer(%struct.lemon* %0, i8* %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i64 @linteger_to_long(%struct.lemon* %0, i8* %3)
%8 = tail call i8* @linteger_create_object_from_long(%struct.lemon* %0, i64 %7)
br label %9
9: ; preds = %2, %6
%10 = phi i8* [ %8, %6 ], [ %3, %2 ]
ret i8* %10
}