#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*/ set_gd(int);
int /*<<< orphan*/ set_ld(int);
int /*<<< orphan*/ test_gd(int);
int /*<<< orphan*/ test_ld(int);
int main() {
  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();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <get_gd@plt>
mov    %rax,-0x10(%rbp)
mov    $0x3,%edi
call   1090 <set_gd@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x3,(%rax)
jne    11b4 <main+0x44>
mov    $0x3,%edi
call   1040 <test_gd@plt>
cmp    $0x0,%eax
jne    11bb <main+0x4b>
mov    $0x0,%al
call   1030 <abort@plt>
mov    $0x0,%al
call   1070 <get_ld@plt>
mov    %rax,-0x10(%rbp)
mov    $0x4,%edi
call   1080 <set_ld@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x4,(%rax)
jne    11f0 <main+0x80>
mov    $0x4,%edi
call   1050 <test_ld@plt>
cmp    $0x0,%eax
jne    11f7 <main+0x87>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <get_gd@plt>
mov    %rax,%rbx
mov    $0x3,%edi
call   1090 <set_gd@plt>
cmpl   $0x3,(%rbx)
jne    11c3 <main+0x53>
mov    $0x3,%edi
call   1040 <test_gd@plt>
test   %eax,%eax
je     11c3 <main+0x53>
xor    %eax,%eax
call   1070 <get_ld@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1080 <set_ld@plt>
cmpl   $0x4,(%rbx)
jne    11c3 <main+0x53>
mov    $0x4,%edi
call   1050 <test_ld@plt>
test   %eax,%eax
je     11c3 <main+0x53>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i32* (...) @get_gd()
store i32* %3, i32** %2
%4 = call i32 @set_gd(i32 3)
%5 = load i32*, i32** %2
%6 = load i32, i32* %5
%7 = icmp ne i32 %6, 3
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = call i32 @test_gd(i32 3)
%10 = icmp ne i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8, %0
%12 = call i32 (...) @abort()
unreachable
13: ; preds = %8
%14 = call i32* (...) @get_ld()
store i32* %14, i32** %2
%15 = call i32 @set_ld(i32 4)
%16 = load i32*, i32** %2
%17 = load i32, i32* %16
%18 = icmp ne i32 %17, 4
br i1 %18, label %22, label %19
19: ; preds = %13
%20 = call i32 @test_ld(i32 4)
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19, %13
%23 = call i32 (...) @abort()
unreachable
24: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%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
ret i32 0
}