#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*/ sprintf(char *, char *, unsigned int, ...);
void ss7_pc_to_str(int ss7type, unsigned int pc, char *str) {
  if (ss7type == (1 << 0)) {
    sprintf(str, "%d", pc);
  } else {
    sprintf(str, "%d-%d-%d", (pc >> 16) & 0xff, (pc >> 8) & 0xff, pc & 0xff);
  }
}


x86 assembly (clang, -O0):
<ss7_pc_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1146 <ss7_pc_to_str+0x36>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xecc(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    117b <ss7_pc_to_str+0x6b>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%edx
shr    $0x10,%edx
and    $0xff,%edx
mov    -0x8(%rbp),%ecx
shr    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%r8d
and    $0xff,%r8d
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ss7_pc_to_str>:
mov    %rdx,%rax
mov    %esi,%edx
cmp    $0x1,%edi
jne    112b <ss7_pc_to_str+0x1b>
lea    0xee5(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
jmp    1030 <sprintf@plt>
mov    %edx,%ecx
shr    $0x10,%ecx
movzbl %cl,%r9d
movzbl %dh,%ecx
movzbl %dl,%r8d
lea    0xebe(%rip),%rsi
mov    %rax,%rdi
mov    %r9d,%edx
xor    %eax,%eax
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"%d-%d-%d\00"
define void @ss7_pc_to_str(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i8*, i8** %6
%11 = load i32, i32* %5
%12 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %24
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = load i32, i32* %5
%16 = lshr i32 %15, 16
%17 = and i32 %16, 255
%18 = load i32, i32* %5
%19 = lshr i32 %18, 8
%20 = and i32 %19, 255
%21 = load i32, i32* %5
%22 = and i32 %21, 255
%23 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %20, i32 %22)
br label %24
24: ; preds = %13, %9
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"%d-%d-%d\00"
define void @ss7_pc_to_str(i32 %0, i32 %1, i8* nocapture writeonly %2) {
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %14
7: ; preds = %3
%8 = lshr i32 %1, 16
%9 = and i32 %8, 255
%10 = lshr i32 %1, 8
%11 = and i32 %10, 255
%12 = and i32 %1, 255
%13 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %11, i32 %12)
br label %14
14: ; preds = %7, %5
ret void
}