#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 uint16_t;

/* Variables and functions */
int /*<<< orphan*/ strncpy(char *, char *, int);
void _address_format(char *format, uint16_t flags) {
  switch (flags & (0xc000)) {
  case (0x0000):
    strncpy(format, "%09o", sizeof("%09o"));
    break;
  case (0x4000):
    strncpy(format, "%06x", sizeof("%06x"));
    break;
  case (0x8000):
    strncpy(format, "%07d", sizeof("%07d"));
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<_address_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xc000,%eax
mov    %eax,-0x10(%rbp)
je     115b <_address_format+0x4b>
jmp    1135 <_address_format+0x25>
mov    -0x10(%rbp),%eax
sub    $0x4000,%eax
je     1175 <_address_format+0x65>
jmp    1148 <_address_format+0x38>
mov    -0x10(%rbp),%eax
sub    $0x8000,%eax
je     118f <_address_format+0x7f>
jmp    11a9 <_address_format+0x99>
mov    -0x8(%rbp),%rdi
lea    0xe9a(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
jmp    11ae <_address_format+0x9e>
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
jmp    11ae <_address_format+0x9e>
mov    -0x8(%rbp),%rdi
lea    0xe70(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
jmp    11ae <_address_format+0x9e>
jmp    11ae <_address_format+0x9e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_address_format>:
and    $0xc000,%esi
cmp    $0x8000,%esi
je     113e <_address_format+0x2e>
test   %si,%si
je     114f <_address_format+0x3f>
movzwl %si,%eax
cmp    $0x4000,%eax
jne    1160 <_address_format+0x50>
lea    0xed1(%rip),%rsi
mov    $0x5,%edx
jmp    1030 <strncpy@plt>
lea    0xec5(%rip),%rsi
mov    $0x5,%edx
jmp    1030 <strncpy@plt>
lea    0xeaa(%rip),%rsi
mov    $0x5,%edx
jmp    1030 <strncpy@plt>
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%09o\00"
@.str.1 = [5 x i8] c"%06x\00"
@.str.2 = [5 x i8] c"%07d\00"
define void @_address_format(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = and i32 %5, 49152
switch i32 %6, label %16 [
i32 0, label %7
i32 16384, label %10
i32 32768, label %13
]
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = call i32 @strncpy(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 5)
br label %17
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @strncpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 5)
br label %17
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = call i32 @strncpy(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 5)
br label %17
16: ; preds = %2
br label %17
17: ; preds = %16, %13, %10, %7
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%09o\00"
@.str.1 = [5 x i8] c"%06x\00"
@.str.2 = [5 x i8] c"%07d\00"
define void @_address_format(i8* %0, i32 %1) {
%3 = trunc i32 %1 to i16
%4 = and i16 %3, -16384
switch i16 %4, label %10 [
i16 0, label %7
i16 16384, label %5
i16 -32768, label %6
]
5: ; preds = %2
br label %7
6: ; preds = %2
br label %7
7: ; preds = %2, %5, %6
%8 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = tail call i32 @strncpy(i8* %0, i8* %8, i32 5)
br label %10
10: ; preds = %7, %2
ret void
}