#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 gl_test {
  int dummy;
};
struct gl_api {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ gl_is_current(struct gl_api *);
struct gl_api *gl_test_api(struct gl_test *);
struct gl_test *gl_test_make(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int test_make_and_ensure_context_is_current(void) {
  struct gl_test *test = gl_test_make(0);
  struct gl_api *api = gl_test_api(test);
  if (!gl_is_current(api)) {
    printf("Not current\n");
    return -1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<test_make_and_ensure_context_is_current>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %edi,%edi
call   1050 <gl_test_make@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <gl_test_api@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <gl_is_current@plt>
cmp    $0x0,%eax
jne    118a <test_make_and_ensure_context_is_current+0x4a>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1191 <test_make_and_ensure_context_is_current+0x51>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_make_and_ensure_context_is_current>:
push   %rbx
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <gl_test_make@plt>
mov    %rax,%rdi
call   1060 <gl_test_api@plt>
mov    %rax,%rdi
call   1040 <gl_is_current@plt>
test   %eax,%eax
jne    116f <test_make_and_ensure_context_is_current+0x2f>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.gl_test = type { i32 }
%struct.gl_api = type { i32 }
@.str = [13 x i8] c"Not current\0A\00"
define i32 @test_make_and_ensure_context_is_current() {
%1 = alloca i32
%2 = alloca %struct.gl_test*
%3 = alloca %struct.gl_api*
%4 = call %struct.gl_test* @gl_test_make(i32 0)
store %struct.gl_test* %4, %struct.gl_test** %2
%5 = load %struct.gl_test*, %struct.gl_test** %2
%6 = call %struct.gl_api* @gl_test_api(%struct.gl_test* %5)
store %struct.gl_api* %6, %struct.gl_api** %3
%7 = load %struct.gl_api*, %struct.gl_api** %3
%8 = call i32 @gl_is_current(%struct.gl_api* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %13
12: ; preds = %0
store i32 0, i32* %1
br label %13
13: ; preds = %12, %10
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
%struct.gl_test = type { i32 }
%struct.gl_api = type { i32 }
@str = [12 x i8] c"Not current\00"
define i32 @test_make_and_ensure_context_is_current() {
%1 = tail call %struct.gl_test* @gl_test_make(i32 0)
%2 = tail call %struct.gl_api* @gl_test_api(%struct.gl_test* %1)
%3 = tail call i32 @gl_is_current(%struct.gl_api* %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %7
7: ; preds = %0, %5
%8 = phi i32 [ -1, %5 ], [ 0, %0 ]
ret i32 %8
}