#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((generic_digits_dump))(struct ss7 *ss7, int messagetype,
                           unsigned char *parm, int len) {
  int oddeven = (parm[0] >> 5) & 0x7;
  char numbuf[64] = "";
  ss7_message(ss7, "\t\t\tType of digits: %x\n", parm[0] & 0x1f);
  ss7_message(ss7, "\t\t\tEncoding Scheme: %x\n", (parm[0] >> 5) & 0x7);
  isup_get_number(numbuf, &parm[1], len - 1, oddeven);
  ss7_message(ss7, "\t\t\tAddress digits: %s\n", numbuf);
  return len;
}


x86 assembly (clang, -O0):
<generic_digits_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    $0x5,%eax
and    $0x7,%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    $0x1f,%edx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl (%rax),%edx
sar    $0x5,%edx
and    $0x7,%edx
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
mov    -0x20(%rbp),%ecx
call   1040 <isup_get_number@plt>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x1c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generic_digits_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    $0x5,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
and    $0x1f,%edx
lea    0xea3(%rip),%rsi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl (%rbx),%edx
shr    $0x5,%edx
lea    0xea6(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
add    $0x1,%rbx
lea    -0x1(%r14),%edx
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %ebp,%ecx
call   1030 <isup_get_number@plt>
lea    0xe95(%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 = [23 x i8] c"\09\09\09Type of digits: %x\0A\00"
@.str.1 = [24 x i8] c"\09\09\09Encoding Scheme: %x\0A\00"
@.str.2 = [23 x i8] c"\09\09\09Address digits: %s\0A\00"
define i32 @generic_digits_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, 5
%16 = and i32 %15, 7
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, 31
%24 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %18, i8* getelementptr inbounds ([23 x i8], [23 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 0
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = ashr i32 %29, 5
%31 = and i32 %30, 7
%32 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %25, i8* getelementptr inbounds ([24 x i8], [24 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 1
%36 = load i32, i32* %8
%37 = sub nsw i32 %36, 1
%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 ([23 x i8], [23 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 = [23 x i8] c"\09\09\09Type of digits: %x\0A\00"
@.str.1 = [24 x i8] c"\09\09\09Encoding Scheme: %x\0A\00"
@.str.2 = [23 x i8] c"\09\09\09Address digits: %s\0A\00"
define i32 @generic_digits_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, 5
%8 = zext i8 %7 to i32
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%10 = and i8 %6, 31
%11 = zext i8 %10 to i32
%12 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i8, i8* %2
%14 = lshr i8 %13, 5
%15 = zext i8 %14 to i32
%16 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i8, i8* %2, i64 1
%18 = add nsw i32 %3, -1
%19 = call i32 @isup_get_number(i8* %9, i8* %17, i32 %18, i32 %8)
%20 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %9)
ret i32 %3
}