#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*/ environ_set_environment(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
void restore_database_environment(char *application_name, char really_yn) {
  if (application_name && *application_name) {
    environ_set_environment("APPASERVER_DATABASE", application_name);
    if (really_yn != 'y') {
      printf("<p>Restoring environment: %s\n", application_name);
    }
  } else {
    environ_set_environment("APPASERVER_DATABASE", "");
    if (really_yn != 'y') {
      printf("<p>Restoring environment: %s\n", "");
    }
  }
}


x86 assembly (clang, -O0):
<restore_database_environment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     117f <restore_database_environment+0x5f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     117f <restore_database_environment+0x5f>
mov    -0x8(%rbp),%rsi
lea    0xea8(%rip),%rdi
call   1030 <environ_set_environment@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x79,%eax
je     117a <restore_database_environment+0x5a>
mov    -0x8(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
jmp    11b7 <restore_database_environment+0x97>
lea    0xe7a(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1030 <environ_set_environment@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x79,%eax
je     11b2 <restore_database_environment+0x92>
lea    0xe6e(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1040 <printf@plt>
jmp    11b7 <restore_database_environment+0x97>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<restore_database_environment>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
test   %rdi,%rdi
je     1153 <restore_database_environment+0x33>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1153 <restore_database_environment+0x33>
lea    0xec7(%rip),%rdi
mov    %rbx,%rsi
call   1030 <environ_set_environment@plt>
cmp    $0x79,%bpl
je     116c <restore_database_environment+0x4c>
lea    0xec6(%rip),%rdi
mov    %rbx,%rsi
jmp    1181 <restore_database_environment+0x61>
lea    0xea6(%rip),%rdi
lea    0xed0(%rip),%rsi
call   1030 <environ_set_environment@plt>
cmp    $0x79,%bpl
jne    1173 <restore_database_environment+0x53>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe9a(%rip),%rdi
lea    0xeb0(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"APPASERVER_DATABASE\00"
@.str.1 = [30 x i8] c"<p>Restoring environment: %s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
define void @restore_database_environment(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
store i8 %1, i8* %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %22
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i32 @environ_set_environment(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8, i8* %4
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 121
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %12
br label %30
22: ; preds = %7, %2
%23 = call i32 @environ_set_environment(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%24 = load i8, i8* %4
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 121
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
br label %30
30: ; preds = %29, %21
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"APPASERVER_DATABASE\00"
@.str.1 = [30 x i8] c"<p>Restoring environment: %s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
define void @restore_database_environment(i8* %0, i8 signext %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = tail call i32 @environ_set_environment(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = icmp eq i8 %1, 121
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %17
12: ; preds = %4, %2
%13 = tail call i32 @environ_set_environment(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i8 %1, 121
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %12, %15, %7, %10
ret void
}