#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 */
struct ss7 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ isup_get_number(char *, unsigned char *, int, int);
int /*<<< orphan*/ ss7_message(struct ss7 *, char *, ...);
int((charge_number_dump))(struct ss7 *ss7, int messagetype, unsigned char *parm,
                          int len) {
  int oddeven = (parm[0] >> 7) & 0x1;
  char numbuf[64] = "";
  ss7_message(ss7, "\t\t\tNature of address: %x\n", parm[0] & 0x7f);
  ss7_message(ss7, "\t\t\tNumbering plan: %x\n", (parm[1] >> 4) & 0x7);
  isup_get_number(numbuf, &parm[2], len - 2, oddeven);
  ss7_message(ss7, "\t\t\tAddress signals: %s\n", numbuf);
  return len;
}


x86 assembly (clang, -O0):
<charge_number_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
sar    $0x7,%eax
and    $0x1,%eax
mov    %eax,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl (%rax),%edx
and    $0x7f,%edx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%edx
sar    $0x4,%edx
and    $0x7,%edx
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x2,%rsi
mov    -0x1c(%rbp),%edx
sub    $0x2,%edx
mov    -0x20(%rbp),%ecx
call   1040 <isup_get_number@plt>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x1c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<charge_number_dump>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rdi,%r15
movzbl (%rdx),%edx
mov    %edx,%ebp
shr    $0x7,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
and    $0x7f,%edx
lea    0xea3(%rip),%rsi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbx),%edx
shr    $0x4,%edx
and    $0x7,%edx
lea    0xea5(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
add    $0x2,%rbx
lea    -0x2(%r14),%edx
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %ebp,%ecx
call   1030 <isup_get_number@plt>
lea    0xe93(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <ss7_message@plt>
mov    %r14d,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ss7 = type { i32 }
@.str = [26 x i8] c"\09\09\09Nature of address: %x\0A\00"
@.str.1 = [23 x i8] c"\09\09\09Numbering plan: %x\0A\00"
@.str.2 = [24 x i8] c"\09\09\09Address signals: %s\0A\00"
define i32 @charge_number_dump(%struct.ss7* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca %struct.ss7*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [64 x i8]
store %struct.ss7* %0, %struct.ss7** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %7
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = ashr i32 %14, 7
%16 = and i32 %15, 1
store i32 %16, i32* %9
%17 = bitcast [64 x i8]* %10 to i8*
%18 = load %struct.ss7*, %struct.ss7** %5
%19 = load i8*, i8** %7
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = and i32 %22, 127
%24 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %18, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load %struct.ss7*, %struct.ss7** %5
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = ashr i32 %29, 4
%31 = and i32 %30, 7
%32 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i64 2
%36 = load i32, i32* %8
%37 = sub nsw i32 %36, 2
%38 = load i32, i32* %9
%39 = call i32 @isup_get_number(i8* %33, i8* %35, i32 %37, i32 %38)
%40 = load %struct.ss7*, %struct.ss7** %5
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%42 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %40, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%43 = load i32, i32* %8
ret i32 %43
}

LLVM IR (-O2):
%struct.ss7 = type { i32 }
@.str = [26 x i8] c"\09\09\09Nature of address: %x\0A\00"
@.str.1 = [23 x i8] c"\09\09\09Numbering plan: %x\0A\00"
@.str.2 = [24 x i8] c"\09\09\09Address signals: %s\0A\00"
define i32 @charge_number_dump(%struct.ss7* %0, i32 %1, i8* %2, i32 returned %3) {
%5 = alloca [64 x i8]
%6 = load i8, i8* %2
%7 = lshr i8 %6, 7
%8 = zext i8 %7 to i32
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%10 = and i8 %6, 127
%11 = zext i8 %10 to i32
%12 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds i8, i8* %2, i64 1
%14 = load i8, i8* %13
%15 = lshr i8 %14, 4
%16 = and i8 %15, 7
%17 = zext i8 %16 to i32
%18 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds i8, i8* %2, i64 2
%20 = add nsw i32 %3, -2
%21 = call i32 @isup_get_number(i8* %9, i8* %19, i32 %20, i32 %8)
%22 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %9)
ret i32 %3
}