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

/* Variables and functions */
int GetColor(struct tagApple *);
struct tagApple *GetInstance();
int /*<<< orphan*/ ReleaseInstance(struct tagApple **);
int /*<<< orphan*/ SetColor(struct tagApple *, int);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  struct tagApple *pApple;
  pApple = GetInstance();
  SetColor(pApple, 1);
  int color = GetColor(pApple);
  printf("color = %d\n", color);
  ReleaseInstance(&pApple);
  assert(pApple == 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <GetInstance@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1060 <SetColor@plt>
mov    -0x10(%rbp),%rdi
call   1080 <GetColor@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1070 <ReleaseInstance@plt>
cmpq   $0x0,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <GetInstance@plt>
mov    %rax,%rbx
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    $0x1,%esi
call   1060 <SetColor@plt>
mov    %rbx,%rdi
call   1080 <GetColor@plt>
lea    0xe70(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x8(%rsp),%rdi
call   1070 <ReleaseInstance@plt>
xor    %edi,%edi
cmpq   $0x0,0x8(%rsp)
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tagApple = type { i32 }
@.str = [12 x i8] c"color = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.tagApple*
%3 = alloca i32
store i32 0, i32* %1
%4 = call %struct.tagApple* (...) @GetInstance()
store %struct.tagApple* %4, %struct.tagApple** %2
%5 = load %struct.tagApple*, %struct.tagApple** %2
%6 = call i32 @SetColor(%struct.tagApple* %5, i32 1)
%7 = load %struct.tagApple*, %struct.tagApple** %2
%8 = call i32 @GetColor(%struct.tagApple* %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @ReleaseInstance(%struct.tagApple** %2)
%12 = load %struct.tagApple*, %struct.tagApple** %2
%13 = icmp eq %struct.tagApple* %12, null
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
ret i32 0
}

LLVM IR (-O2):
%struct.tagApple = type { i32 }
@.str = [12 x i8] c"color = %d\0A\00"
define i32 @main() {
%1 = alloca %struct.tagApple*
%2 = bitcast %struct.tagApple** %1 to i8*
%3 = tail call %struct.tagApple* (...) @GetInstance()
store %struct.tagApple* %3, %struct.tagApple** %1
%4 = tail call i32 @SetColor(%struct.tagApple* %3, i32 1)
%5 = tail call i32 @GetColor(%struct.tagApple* %3)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @ReleaseInstance(%struct.tagApple** %1)
%8 = load %struct.tagApple*, %struct.tagApple** %1
%9 = icmp eq %struct.tagApple* %8, null
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
ret i32 0
}