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

/* Variables and functions */
int /*<<< orphan*/ closeHive(struct hive *);
struct hive *openHive(char *, int /*<<< orphan*/);
int /*<<< orphan*/ put_dword(struct hive *, int /*<<< orphan*/, char *, int,
                             int);
int /*<<< orphan*/ writeHive(struct hive *);
int main() {
  struct hive *myhive;
  myhive = openHive("SYSTEM", 0);
  if (myhive == 0)
    myhive = openHive("system", 0);
  if (myhive == 0)
    myhive = openHive("System", 0);
  put_dword(myhive, 0, "ControlSet001\\Services\\Spooler\\Start", (1 | 128), 2);
  put_dword(myhive, 0, "ControlSet002\\Services\\Spooler\\Start", (1 | 128), 2);
  writeHive(myhive);
  closeHive(myhive);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %esi,%esi
call   1030 <openHive@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117e <main+0x3e>
lea    0xe94(%rip),%rdi
xor    %esi,%esi
call   1030 <openHive@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119b <main+0x5b>
lea    0xe7e(%rip),%rdi
xor    %esi,%esi
call   1030 <openHive@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
lea    0xe6d(%rip),%rdx
mov    $0x81,%ecx
mov    $0x2,%r8d
call   1050 <put_dword@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
lea    0xe75(%rip),%rdx
mov    $0x81,%ecx
mov    $0x2,%r8d
call   1050 <put_dword@plt>
mov    -0x10(%rbp),%rdi
call   1040 <writeHive@plt>
mov    -0x10(%rbp),%rdi
call   1060 <closeHive@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
xor    %esi,%esi
call   1030 <openHive@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    117e <main+0x3e>
lea    0xea9(%rip),%rdi
xor    %esi,%esi
call   1030 <openHive@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    117e <main+0x3e>
lea    0xe9a(%rip),%rdi
xor    %esi,%esi
call   1030 <openHive@plt>
mov    %rax,%rbx
lea    0xe90(%rip),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x81,%ecx
mov    $0x2,%r8d
call   1050 <put_dword@plt>
lea    0xe99(%rip),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x81,%ecx
mov    $0x2,%r8d
call   1050 <put_dword@plt>
mov    %rbx,%rdi
call   1040 <writeHive@plt>
mov    %rbx,%rdi
call   1060 <closeHive@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.hive = type { i32 }
@.str = [7 x i8] c"SYSTEM\00"
@.str.1 = [7 x i8] c"system\00"
@.str.2 = [7 x i8] c"System\00"
@.str.3 = [37 x i8] c"ControlSet001\\Services\\Spooler\\Start\00"
@.str.4 = [37 x i8] c"ControlSet002\\Services\\Spooler\\Start\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.hive*
store i32 0, i32* %1
%3 = call %struct.hive* @openHive(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 0)
store %struct.hive* %3, %struct.hive** %2
%4 = load %struct.hive*, %struct.hive** %2
%5 = icmp eq %struct.hive* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call %struct.hive* @openHive(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 0)
store %struct.hive* %7, %struct.hive** %2
br label %8
8: ; preds = %6, %0
%9 = load %struct.hive*, %struct.hive** %2
%10 = icmp eq %struct.hive* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call %struct.hive* @openHive(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
store %struct.hive* %12, %struct.hive** %2
br label %13
13: ; preds = %11, %8
%14 = load %struct.hive*, %struct.hive** %2
%15 = call i32 @put_dword(%struct.hive* %14, i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 129, i32 2)
%16 = load %struct.hive*, %struct.hive** %2
%17 = call i32 @put_dword(%struct.hive* %16, i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 129, i32 2)
%18 = load %struct.hive*, %struct.hive** %2
%19 = call i32 @writeHive(%struct.hive* %18)
%20 = load %struct.hive*, %struct.hive** %2
%21 = call i32 @closeHive(%struct.hive* %20)
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
%struct.hive = type { i32 }
@.str = [7 x i8] c"SYSTEM\00"
@.str.1 = [7 x i8] c"system\00"
@.str.2 = [7 x i8] c"System\00"
@.str.3 = [37 x i8] c"ControlSet001\\Services\\Spooler\\Start\00"
@.str.4 = [37 x i8] c"ControlSet002\\Services\\Spooler\\Start\00"
define i32 @main() {
%1 = tail call %struct.hive* @openHive(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = icmp eq %struct.hive* %1, null
br i1 %2, label %3, label %8
3: ; preds = %0
%4 = tail call %struct.hive* @openHive(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 0)
%5 = icmp eq %struct.hive* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call %struct.hive* @openHive(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
br label %8
8: ; preds = %0, %6, %3
%9 = phi %struct.hive* [ %7, %6 ], [ %4, %3 ], [ %1, %0 ]
%10 = tail call i32 @put_dword(%struct.hive* %9, i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 129, i32 2)
%11 = tail call i32 @put_dword(%struct.hive* %9, i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 129, i32 2)
%12 = tail call i32 @writeHive(%struct.hive* %9)
%13 = tail call i32 @closeHive(%struct.hive* %9)
ret i32 0
}