#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 */

/* Variables and functions */
int /*<<< orphan*/ abort();
int *get_gd();
int *get_ld();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ set_gd(int);
int /*<<< orphan*/ set_ld(int);
int /*<<< orphan*/ test_gd(int);
int /*<<< orphan*/ test_ld(int);
int do_test(void) {
  int *p;
  p = get_gd();
  set_gd(3);
  if (*p != 3 || !test_gd(3))
    abort();
  p = get_ld();
  set_ld(4);
  if (*p != 4 || !test_ld(4))
    abort();
  printf("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1070 <get_gd@plt>
mov    %rax,-0x8(%rbp)
mov    $0x3,%edi
call   10a0 <set_gd@plt>
mov    -0x8(%rbp),%rax
cmpl   $0x3,(%rax)
jne    11bd <do_test+0x3d>
mov    $0x3,%edi
call   1040 <test_gd@plt>
cmp    $0x0,%eax
jne    11c4 <do_test+0x44>
mov    $0x0,%al
call   1030 <abort@plt>
mov    $0x0,%al
call   1080 <get_ld@plt>
mov    %rax,-0x8(%rbp)
mov    $0x4,%edi
call   1090 <set_ld@plt>
mov    -0x8(%rbp),%rax
cmpl   $0x4,(%rax)
jne    11f9 <do_test+0x79>
mov    $0x4,%edi
call   1060 <test_ld@plt>
cmp    $0x0,%eax
jne    1200 <do_test+0x80>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xdf9(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbx
xor    %eax,%eax
call   1070 <get_gd@plt>
mov    %rax,%rbx
mov    $0x3,%edi
call   10a0 <set_gd@plt>
cmpl   $0x3,(%rbx)
jne    11df <do_test+0x5f>
mov    $0x3,%edi
call   1040 <test_gd@plt>
test   %eax,%eax
je     11df <do_test+0x5f>
xor    %eax,%eax
call   1080 <get_ld@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1090 <set_ld@plt>
cmpl   $0x4,(%rbx)
jne    11df <do_test+0x5f>
mov    $0x4,%edi
call   1060 <test_ld@plt>
test   %eax,%eax
je     11df <do_test+0x5f>
lea    0xe2a(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"PASS\0A\00"
define i32 @do_test() {
%1 = alloca i32*
%2 = call i32* (...) @get_gd()
store i32* %2, i32** %1
%3 = call i32 @set_gd(i32 3)
%4 = load i32*, i32** %1
%5 = load i32, i32* %4
%6 = icmp ne i32 %5, 3
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i32 @test_gd(i32 3)
%9 = icmp ne i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7, %0
%11 = call i32 (...) @abort()
unreachable
12: ; preds = %7
%13 = call i32* (...) @get_ld()
store i32* %13, i32** %1
%14 = call i32 @set_ld(i32 4)
%15 = load i32*, i32** %1
%16 = load i32, i32* %15
%17 = icmp ne i32 %16, 4
br i1 %17, label %21, label %18
18: ; preds = %12
%19 = call i32 @test_ld(i32 4)
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18, %12
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [5 x i8] c"PASS\00"
define i32 @do_test() {
%1 = tail call i32* (...) @get_gd()
%2 = tail call i32 @set_gd(i32 3)
%3 = load i32, i32* %1
%4 = icmp eq i32 %3, 3
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @test_gd(i32 3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5, %0
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %5
%11 = tail call i32* (...) @get_ld()
%12 = tail call i32 @set_ld(i32 4)
%13 = load i32, i32* %11
%14 = icmp eq i32 %13, 4
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = tail call i32 @test_ld(i32 4)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15, %10
%19 = tail call i32 (...) @abort()
unreachable
20: ; preds = %15
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret i32 0
}