#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*/ ClearAppFlagsAndSegv_asm();
int /*<<< orphan*/ SetAppFlagsAndSegv_asm();
int /*<<< orphan*/ printf(char *);
int DoTest(unsigned int tnum) {
  switch (tnum) {
  case 0:
    printf("AllFlagsSet\n");
    SetAppFlagsAndSegv_asm();
    return (1);
  case 1:
    printf("AllFlagsClear\n");
    ClearAppFlagsAndSegv_asm();
    return (1);
  default:
    return (0);
  }
}


x86 assembly (clang, -O0):
<DoTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
test   %eax,%eax
je     115f <DoTest+0x2f>
jmp    114e <DoTest+0x1e>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
je     117e <DoTest+0x4e>
jmp    119d <DoTest+0x6d>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <SetAppFlagsAndSegv_asm@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a4 <DoTest+0x74>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <ClearAppFlagsAndSegv_asm@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a4 <DoTest+0x74>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoTest>:
push   %rax
cmp    $0x1,%edi
je     1151 <DoTest+0x21>
xor    %eax,%eax
test   %edi,%edi
jne    1169 <DoTest+0x39>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <SetAppFlagsAndSegv_asm@plt>
jmp    1164 <DoTest+0x34>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <ClearAppFlagsAndSegv_asm@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"AllFlagsSet\0A\00"
@.str.1 = [15 x i8] c"AllFlagsClear\0A\00"
define i32 @DoTest(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %11 [
i32 0, label %5
i32 1, label %8
]
5: ; preds = %1
%6 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @SetAppFlagsAndSegv_asm()
store i32 1, i32* %2
br label %12
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (...) @ClearAppFlagsAndSegv_asm()
store i32 1, i32* %2
br label %12
11: ; preds = %1
store i32 0, i32* %2
br label %12
12: ; preds = %11, %8, %5
%13 = load i32, i32* %2
ret i32 %13
}

LLVM IR (-O2):
@str = [14 x i8] c"AllFlagsClear\00"
@str.2 = [12 x i8] c"AllFlagsSet\00"
define i32 @DoTest(i32 %0) {
switch i32 %0, label %8 [
i32 0, label %2
i32 1, label %5
]
2: ; preds = %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.2, i64 0, i64 0))
%4 = tail call i32 (...) @SetAppFlagsAndSegv_asm()
br label %8
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (...) @ClearAppFlagsAndSegv_asm()
br label %8
8: ; preds = %1, %5, %2
%9 = phi i32 [ 1, %5 ], [ 1, %2 ], [ 0, %1 ]
ret i32 %9
}