#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
FILE *select_mirror(char *mirror_list, int are_updating) {
  FILE *fp;
  switch (are_updating) {
  case -1:
    printf("Creating mirror file: %s\n", mirror_list);
    fp = fopen(mirror_list, "w+");
    break;
  case 0:
    fp = fopen(mirror_list, "r");
    break;
  case 1:
    fp = fopen(mirror_list, "w");
    break;
  default:
    return NULL;
    break;
  }
  return fp;
}


x86 assembly (clang, -O0):
<select_mirror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0xffffffff,%eax
je     1164 <select_mirror+0x44>
jmp    1143 <select_mirror+0x23>
mov    -0x24(%rbp),%eax
test   %eax,%eax
je     118d <select_mirror+0x6d>
jmp    1153 <select_mirror+0x33>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
je     11a6 <select_mirror+0x86>
jmp    11bf <select_mirror+0x9f>
mov    -0x10(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    11cc <select_mirror+0xac>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    11cc <select_mirror+0xac>
mov    -0x10(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    11cc <select_mirror+0xac>
movq   $0x0,-0x8(%rbp)
jmp    11d4 <select_mirror+0xb4>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_mirror>:
push   %rbx
mov    %rdi,%rbx
cmp    $0x1,%esi
je     114a <select_mirror+0x2a>
test   %esi,%esi
je     1153 <select_mirror+0x33>
cmp    $0xffffffff,%esi
jne    1163 <select_mirror+0x43>
lea    0xec7(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xed2(%rip),%rsi
jmp    115a <select_mirror+0x3a>
lea    0xece(%rip),%rsi
jmp    115a <select_mirror+0x3a>
lea    0xec3(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <fopen@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Creating mirror file: %s\0A\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
define i32* @select_mirror(i8* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
switch i32 %7, label %19 [
i32 -1, label %8
i32 0, label %13
i32 1, label %16
]
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %4
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %6
br label %20
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %15, i32** %6
br label %20
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %18, i32** %6
br label %20
19: ; preds = %2
store i32* null, i32** %3
br label %22
20: ; preds = %16, %13, %8
%21 = load i32*, i32** %6
store i32* %21, i32** %3
br label %22
22: ; preds = %20, %19
%23 = load i32*, i32** %3
ret i32* %23
}

LLVM IR (-O2):
@.str = [26 x i8] c"Creating mirror file: %s\0A\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
define noalias i32* @select_mirror(i8* %0, i32 %1) {
switch i32 %1, label %9 [
i32 -1, label %3
i32 0, label %6
i32 1, label %5
]
3: ; preds = %2
%4 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %6
5: ; preds = %2
br label %6
6: ; preds = %2, %5, %3
%7 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %2 ]
%8 = tail call i32* @fopen(i8* %0, i8* %7)
br label %9
9: ; preds = %6, %2
%10 = phi i32* [ null, %2 ], [ %8, %6 ]
ret i32* %10
}