#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 scalar_t__ time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
int DecodePDUMessage_GSM_7bit(unsigned char const *, int, char *, int const);
int /*<<< orphan*/ DecodePhoneNumber(unsigned char const *, int const, char *);
int SwapDecimalNibble(unsigned char const);
int /*<<< orphan*/ memcpy(char *, unsigned char const *, int const);
scalar_t__ mktime(struct tm *);
int pdu_decode(const unsigned char *buffer, int buffer_length,
               time_t *output_sms_time, char *output_sender_phone_number,
               int sender_phone_number_size, char *output_sms_text,
               int sms_text_size, int *tp_dcs, int *user_payload_header_size) {
  if (buffer_length <= 0)
    return -1;
  const int sms_deliver_start = 1 + buffer[0];
  if (sms_deliver_start + 1 > buffer_length)
    return -2;
  const int user_data_header_length = (buffer[sms_deliver_start] >> 4);
  *user_payload_header_size = user_data_header_length;
  const int sender_number_length = buffer[sms_deliver_start + 1];
  if (sender_number_length + 1 > sender_phone_number_size)
    return -3;
  DecodePhoneNumber(buffer + sms_deliver_start + 3, sender_number_length,
                    output_sender_phone_number);
  const int sms_pid_start =
      sms_deliver_start + 3 + (buffer[sms_deliver_start + 1] + 1) / 2;
  struct tm sms_broken_time;
  sms_broken_time.tm_year = 100 + SwapDecimalNibble(buffer[sms_pid_start + 2]);
  sms_broken_time.tm_mon = SwapDecimalNibble(buffer[sms_pid_start + 3]) - 1;
  sms_broken_time.tm_mday = SwapDecimalNibble(buffer[sms_pid_start + 4]);
  sms_broken_time.tm_hour = SwapDecimalNibble(buffer[sms_pid_start + 5]);
  sms_broken_time.tm_min = SwapDecimalNibble(buffer[sms_pid_start + 6]);
  sms_broken_time.tm_sec = SwapDecimalNibble(buffer[sms_pid_start + 7]);
  const char gmt_offset = SwapDecimalNibble(buffer[sms_pid_start + 8]);
  (*output_sms_time) = mktime(&sms_broken_time) - gmt_offset * 15 * 60;
  const int sms_start = sms_pid_start + 2 + 7;
  if (sms_start + 1 > buffer_length)
    return -1;
  const int output_sms_text_length = buffer[sms_start];
  if (sms_text_size < output_sms_text_length)
    return -1;
  const int sms_tp_dcs_start = sms_pid_start + 1;
  *tp_dcs = buffer[sms_tp_dcs_start];
  switch (*tp_dcs) {
  case 0: {
    int decoded_sms_text_size = DecodePDUMessage_GSM_7bit(
        buffer + sms_start + 1, buffer_length - (sms_start + 1),
        output_sms_text, output_sms_text_length);
    if (decoded_sms_text_size != output_sms_text_length)
      return -1;
    break;
  }
  case 8: {
    memcpy(output_sms_text, buffer + sms_start + 1, output_sms_text_length);
    break;
  }
  default:
    break;
  }
  if (output_sms_text_length < sms_text_size)
    output_sms_text[output_sms_text_length] = 0;
  else
    output_sms_text[sms_text_size - 1] = 0;
  return output_sms_text_length;
}


x86 assembly (clang, -O0):
<pdu_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     1193 <pdu_decode+0x43>
movl   $0xffffffff,-0x4(%rbp)
jmp    1455 <pdu_decode+0x305>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
cmp    -0x14(%rbp),%eax
jle    11bb <pdu_decode+0x6b>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1455 <pdu_decode+0x305>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
sar    $0x4,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%ecx
mov    0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
cmp    -0x2c(%rbp),%eax
jle    1205 <pdu_decode+0xb5>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1455 <pdu_decode+0x305>
mov    -0x10(%rbp),%rdi
movslq -0x3c(%rbp),%rax
add    %rax,%rdi
add    $0x3,%rdi
mov    -0x44(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1030 <DecodePhoneNumber@plt>
mov    -0x3c(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x78(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1050 <SwapDecimalNibble@plt>
add    $0x64,%eax
mov    %eax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1050 <SwapDecimalNibble@plt>
sub    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1050 <SwapDecimalNibble@plt>
mov    %eax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x5,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1050 <SwapDecimalNibble@plt>
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x6,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1050 <SwapDecimalNibble@plt>
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x7,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1050 <SwapDecimalNibble@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%ecx
add    $0x8,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1050 <SwapDecimalNibble@plt>
mov    %al,-0x61(%rbp)
lea    -0x60(%rbp),%rdi
call   1060 <mktime@plt>
mov    %rax,%rcx
movsbl -0x61(%rbp),%eax
imul   $0xf,%eax,%eax
imul   $0x3c,%eax,%eax
cltq
sub    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x48(%rbp),%eax
add    $0x2,%eax
add    $0x7,%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
cmp    -0x14(%rbp),%eax
jle    134d <pdu_decode+0x1fd>
movl   $0xffffffff,-0x4(%rbp)
jmp    1455 <pdu_decode+0x305>
mov    -0x10(%rbp),%rax
movslq -0x68(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x6c(%rbp)
mov    0x10(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jge    1374 <pdu_decode+0x224>
movl   $0xffffffff,-0x4(%rbp)
jmp    1455 <pdu_decode+0x305>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x70(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
test   %eax,%eax
je     13b6 <pdu_decode+0x266>
jmp    13a5 <pdu_decode+0x255>
mov    -0x7c(%rbp),%eax
sub    $0x8,%eax
je     13fc <pdu_decode+0x2ac>
jmp    141c <pdu_decode+0x2cc>
mov    -0x10(%rbp),%rdi
movslq -0x68(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x14(%rbp),%esi
mov    -0x68(%rbp),%eax
add    $0x1,%eax
sub    %eax,%esi
mov    -0x38(%rbp),%rdx
mov    -0x6c(%rbp),%ecx
call   1070 <DecodePDUMessage_GSM_7bit@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x6c(%rbp),%eax
je     13f7 <pdu_decode+0x2a7>
movl   $0xffffffff,-0x4(%rbp)
jmp    1455 <pdu_decode+0x305>
jmp    1421 <pdu_decode+0x2d1>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x68(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
mov    -0x6c(%rbp),%edx
call   1040 <memcpy@plt>
jmp    1421 <pdu_decode+0x2d1>
jmp    1421 <pdu_decode+0x2d1>
mov    -0x6c(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    143e <pdu_decode+0x2ee>
mov    -0x38(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    144f <pdu_decode+0x2ff>
mov    -0x38(%rbp),%rax
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pdu_decode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %esi,%esi
jle    12c4 <pdu_decode+0x174>
mov    %esi,%r12d
mov    %rdi,%r13
movzbl (%rdi),%ebx
lea    0x2(%rbx),%r14
mov    $0xfffffffe,%ebp
cmp    %esi,%r14d
ja     12c9 <pdu_decode+0x179>
mov    %rdx,%r15
mov    0x70(%rsp),%rax
movzbl 0x1(%rbx,%r13,1),%edx
shr    $0x4,%edx
mov    %edx,(%rax)
movzbl 0x0(%r13,%r14,1),%esi
mov    $0xfffffffd,%ebp
cmp    %r8d,%esi
jge    12c9 <pdu_decode+0x179>
mov    %r9,0x8(%rsp)
lea    (%rbx,%r13,1),%rdi
add    $0x1,%rdi
add    $0x3,%rdi
mov    %rcx,%rdx
call   1030 <DecodePhoneNumber@plt>
movzbl 0x0(%r13,%r14,1),%eax
add    $0x1,%rax
shr    %rax
lea    (%rbx,%rax,1),%rbp
add    %rax,%rbx
add    $0x4,%rbx
movzbl 0x6(%r13,%rbp,1),%edi
call   1050 <SwapDecimalNibble@plt>
add    $0x64,%eax
mov    %eax,0x10(%rsp)
movzbl 0x7(%r13,%rbp,1),%edi
call   1050 <SwapDecimalNibble@plt>
add    $0xffffffff,%eax
mov    %eax,0x14(%rsp)
movzbl 0x8(%r13,%rbp,1),%edi
call   1050 <SwapDecimalNibble@plt>
mov    %eax,0x18(%rsp)
movzbl 0x9(%r13,%rbp,1),%edi
call   1050 <SwapDecimalNibble@plt>
mov    %eax,0x1c(%rsp)
movzbl 0xa(%r13,%rbp,1),%edi
call   1050 <SwapDecimalNibble@plt>
mov    %eax,0x20(%rsp)
movzbl 0xb(%r13,%rbp,1),%edi
call   1050 <SwapDecimalNibble@plt>
mov    %eax,0x24(%rsp)
movzbl 0xc(%r13,%rbp,1),%edi
call   1050 <SwapDecimalNibble@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%rdi
call   1060 <mktime@plt>
movsbl %bpl,%ecx
imul   $0x384,%ecx,%ecx
movslq %ecx,%rcx
sub    %rcx,%rax
mov    %rax,(%r15)
lea    0xa(%rbx),%eax
mov    $0xffffffff,%ebp
cmp    %r12d,%eax
ja     12c9 <pdu_decode+0x179>
mov    0x60(%rsp),%r14d
movzbl 0x9(%rbx,%r13,1),%r15d
cmp    %r14d,%r15d
mov    0x8(%rsp),%rdx
jg     12c9 <pdu_decode+0x179>
mov    0x68(%rsp),%rdi
lea    (%rbx,%r13,1),%rsi
add    $0x9,%rsi
movzbl 0x1(%rbx,%r13,1),%ecx
mov    %ecx,(%rdi)
cmp    $0x8,%ecx
je     12da <pdu_decode+0x18a>
test   %cl,%cl
jne    12ee <pdu_decode+0x19e>
add    $0x1,%rsi
sub    %eax,%r12d
mov    %rsi,%rdi
mov    %r12d,%esi
mov    %r15d,%ecx
call   1070 <DecodePDUMessage_GSM_7bit@plt>
mov    0x8(%rsp),%rdx
cmp    %r15d,%eax
jne    12c9 <pdu_decode+0x179>
jmp    12ee <pdu_decode+0x19e>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x1,%rsi
mov    %rdx,%rdi
mov    %r15d,%edx
call   1040 <memcpy@plt>
mov    0x8(%rsp),%rdx
lea    -0x1(%r14),%eax
cmp    %r14d,%r15d
mov    %r15d,%ecx
cltq
cmovl  %rcx,%rax
movb   $0x0,(%rdx,%rax,1)
mov    %r15d,%ebp
jmp    12c9 <pdu_decode+0x179>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define i32 @pdu_decode(i8* %0, i32 %1, i64* %2, i8* %3, i32 %4, i8* %5, i32 %6, i32* %7, i32* %8) {
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i64*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca %struct.tm
%25 = alloca i8
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
store i8* %0, i8** %11
store i32 %1, i32* %12
store i64* %2, i64** %13
store i8* %3, i8** %14
store i32 %4, i32* %15
store i8* %5, i8** %16
store i32 %6, i32* %17
store i32* %7, i32** %18
store i32* %8, i32** %19
%30 = load i32, i32* %12
%31 = icmp sle i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %9
store i32 -1, i32* %10
br label %229
33: ; preds = %9
%34 = load i8*, i8** %11
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = add nsw i32 1, %37
store i32 %38, i32* %20
%39 = load i32, i32* %20
%40 = add nsw i32 %39, 1
%41 = load i32, i32* %12
%42 = icmp sgt i32 %40, %41
br i1 %42, label %43, label %44
43: ; preds = %33
store i32 -2, i32* %10
br label %229
44: ; preds = %33
%45 = load i8*, i8** %11
%46 = load i32, i32* %20
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = ashr i32 %50, 4
store i32 %51, i32* %21
%52 = load i32, i32* %21
%53 = load i32*, i32** %19
store i32 %52, i32* %53
%54 = load i8*, i8** %11
%55 = load i32, i32* %20
%56 = add nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %54, i64 %57
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
store i32 %60, i32* %22
%61 = load i32, i32* %22
%62 = add nsw i32 %61, 1
%63 = load i32, i32* %15
%64 = icmp sgt i32 %62, %63
br i1 %64, label %65, label %66
65: ; preds = %44
store i32 -3, i32* %10
br label %229
66: ; preds = %44
%67 = load i8*, i8** %11
%68 = load i32, i32* %20
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = getelementptr inbounds i8, i8* %70, i64 3
%72 = load i32, i32* %22
%73 = load i8*, i8** %14
%74 = call i32 @DecodePhoneNumber(i8* %71, i32 %72, i8* %73)
%75 = load i32, i32* %20
%76 = add nsw i32 %75, 3
%77 = load i8*, i8** %11
%78 = load i32, i32* %20
%79 = add nsw i32 %78, 1
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %77, i64 %80
%82 = load i8, i8* %81
%83 = zext i8 %82 to i32
%84 = add nsw i32 %83, 1
%85 = sdiv i32 %84, 2
%86 = add nsw i32 %76, %85
store i32 %86, i32* %23
%87 = load i8*, i8** %11
%88 = load i32, i32* %23
%89 = add nsw i32 %88, 2
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %87, i64 %90
%92 = load i8, i8* %91
%93 = call i32 @SwapDecimalNibble(i8 zeroext %92)
%94 = add nsw i32 100, %93
%95 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 0
store i32 %94, i32* %95
%96 = load i8*, i8** %11
%97 = load i32, i32* %23
%98 = add nsw i32 %97, 3
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %96, i64 %99
%101 = load i8, i8* %100
%102 = call i32 @SwapDecimalNibble(i8 zeroext %101)
%103 = sub nsw i32 %102, 1
%104 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 1
store i32 %103, i32* %104
%105 = load i8*, i8** %11
%106 = load i32, i32* %23
%107 = add nsw i32 %106, 4
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %105, i64 %108
%110 = load i8, i8* %109
%111 = call i32 @SwapDecimalNibble(i8 zeroext %110)
%112 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 2
store i32 %111, i32* %112
%113 = load i8*, i8** %11
%114 = load i32, i32* %23
%115 = add nsw i32 %114, 5
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %113, i64 %116
%118 = load i8, i8* %117
%119 = call i32 @SwapDecimalNibble(i8 zeroext %118)
%120 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 3
store i32 %119, i32* %120
%121 = load i8*, i8** %11
%122 = load i32, i32* %23
%123 = add nsw i32 %122, 6
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8, i8* %121, i64 %124
%126 = load i8, i8* %125
%127 = call i32 @SwapDecimalNibble(i8 zeroext %126)
%128 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 4
store i32 %127, i32* %128
%129 = load i8*, i8** %11
%130 = load i32, i32* %23
%131 = add nsw i32 %130, 7
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %129, i64 %132
%134 = load i8, i8* %133
%135 = call i32 @SwapDecimalNibble(i8 zeroext %134)
%136 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 5
store i32 %135, i32* %136
%137 = load i8*, i8** %11
%138 = load i32, i32* %23
%139 = add nsw i32 %138, 8
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8, i8* %137, i64 %140
%142 = load i8, i8* %141
%143 = call i32 @SwapDecimalNibble(i8 zeroext %142)
%144 = trunc i32 %143 to i8
store i8 %144, i8* %25
%145 = call i64 @mktime(%struct.tm* %24)
%146 = load i8, i8* %25
%147 = sext i8 %146 to i32
%148 = mul nsw i32 %147, 15
%149 = mul nsw i32 %148, 60
%150 = sext i32 %149 to i64
%151 = sub nsw i64 %145, %150
%152 = load i64*, i64** %13
store i64 %151, i64* %152
%153 = load i32, i32* %23
%154 = add nsw i32 %153, 2
%155 = add nsw i32 %154, 7
store i32 %155, i32* %26
%156 = load i32, i32* %26
%157 = add nsw i32 %156, 1
%158 = load i32, i32* %12
%159 = icmp sgt i32 %157, %158
br i1 %159, label %160, label %161
160: ; preds = %66
store i32 -1, i32* %10
br label %229
161: ; preds = %66
%162 = load i8*, i8** %11
%163 = load i32, i32* %26
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds i8, i8* %162, i64 %164
%166 = load i8, i8* %165
%167 = zext i8 %166 to i32
store i32 %167, i32* %27
%168 = load i32, i32* %17
%169 = load i32, i32* %27
%170 = icmp slt i32 %168, %169
br i1 %170, label %171, label %172
171: ; preds = %161
store i32 -1, i32* %10
br label %229
172: ; preds = %161
%173 = load i32, i32* %23
%174 = add nsw i32 %173, 1
store i32 %174, i32* %28
%175 = load i8*, i8** %11
%176 = load i32, i32* %28
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds i8, i8* %175, i64 %177
%179 = load i8, i8* %178
%180 = zext i8 %179 to i32
%181 = load i32*, i32** %18
store i32 %180, i32* %181
%182 = load i32*, i32** %18
%183 = load i32, i32* %182
switch i32 %183, label %211 [
i32 0, label %184
i32 8, label %202
]
184: ; preds = %172
%185 = load i8*, i8** %11
%186 = load i32, i32* %26
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds i8, i8* %185, i64 %187
%189 = getelementptr inbounds i8, i8* %188, i64 1
%190 = load i32, i32* %12
%191 = load i32, i32* %26
%192 = add nsw i32 %191, 1
%193 = sub nsw i32 %190, %192
%194 = load i8*, i8** %16
%195 = load i32, i32* %27
%196 = call i32 @DecodePDUMessage_GSM_7bit(i8* %189, i32 %193, i8* %194, i32 %195)
store i32 %196, i32* %29
%197 = load i32, i32* %29
%198 = load i32, i32* %27
%199 = icmp ne i32 %197, %198
br i1 %199, label %200, label %201
200: ; preds = %184
store i32 -1, i32* %10
br label %229
201: ; preds = %184
br label %212
202: ; preds = %172
%203 = load i8*, i8** %16
%204 = load i8*, i8** %11
%205 = load i32, i32* %26
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds i8, i8* %204, i64 %206
%208 = getelementptr inbounds i8, i8* %207, i64 1
%209 = load i32, i32* %27
%210 = call i32 @memcpy(i8* %203, i8* %208, i32 %209)
br label %212
211: ; preds = %172
br label %212
212: ; preds = %211, %202, %201
%213 = load i32, i32* %27
%214 = load i32, i32* %17
%215 = icmp slt i32 %213, %214
br i1 %215, label %216, label %221
216: ; preds = %212
%217 = load i8*, i8** %16
%218 = load i32, i32* %27
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds i8, i8* %217, i64 %219
store i8 0, i8* %220
br label %227
221: ; preds = %212
%222 = load i8*, i8** %16
%223 = load i32, i32* %17
%224 = sub nsw i32 %223, 1
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds i8, i8* %222, i64 %225
store i8 0, i8* %226
br label %227
227: ; preds = %221, %216
%228 = load i32, i32* %27
store i32 %228, i32* %10
br label %229
229: ; preds = %227, %200, %171, %160, %65, %43, %32
%230 = load i32, i32* %10
ret i32 %230
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define i32 @pdu_decode(i8* %0, i32 %1, i64* nocapture writeonly %2, i8* %3, i32 %4, i8* %5, i32 %6, i32* nocapture writeonly %7, i32* nocapture writeonly %8) {
%10 = alloca %struct.tm
%11 = icmp slt i32 %1, 1
br i1 %11, label %120, label %12
12: ; preds = %9
%13 = load i8, i8* %0
%14 = zext i8 %13 to i32
%15 = add nuw nsw i32 %14, 2
%16 = icmp ugt i32 %15, %1
br i1 %16, label %120, label %17
17: ; preds = %12
%18 = add nuw nsw i32 %14, 1
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = lshr i8 %21, 4
%23 = zext i8 %22 to i32
store i32 %23, i32* %8
%24 = zext i32 %15 to i64
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = icmp slt i32 %27, %4
br i1 %28, label %29, label %120
29: ; preds = %17
%30 = getelementptr inbounds i8, i8* %20, i64 3
%31 = tail call i32 @DecodePhoneNumber(i8* %30, i32 %27, i8* %3)
%32 = add nuw nsw i32 %14, 4
%33 = load i8, i8* %25
%34 = zext i8 %33 to i32
%35 = add nuw nsw i32 %34, 1
%36 = lshr i32 %35, 1
%37 = add nuw nsw i32 %32, %36
%38 = bitcast %struct.tm* %10 to i8*
%39 = add nuw nsw i32 %37, 2
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %0, i64 %40
%42 = load i8, i8* %41
%43 = tail call i32 @SwapDecimalNibble(i8 zeroext %42)
%44 = add nsw i32 %43, 100
%45 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 0
store i32 %44, i32* %45
%46 = add nuw nsw i32 %37, 3
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %0, i64 %47
%49 = load i8, i8* %48
%50 = tail call i32 @SwapDecimalNibble(i8 zeroext %49)
%51 = add nsw i32 %50, -1
%52 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 1
store i32 %51, i32* %52
%53 = add nuw nsw i32 %37, 4
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %0, i64 %54
%56 = load i8, i8* %55
%57 = tail call i32 @SwapDecimalNibble(i8 zeroext %56)
%58 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 2
store i32 %57, i32* %58
%59 = add nuw nsw i32 %37, 5
%60 = zext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %0, i64 %60
%62 = load i8, i8* %61
%63 = tail call i32 @SwapDecimalNibble(i8 zeroext %62)
%64 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 3
store i32 %63, i32* %64
%65 = add nuw nsw i32 %37, 6
%66 = zext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %0, i64 %66
%68 = load i8, i8* %67
%69 = tail call i32 @SwapDecimalNibble(i8 zeroext %68)
%70 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 4
store i32 %69, i32* %70
%71 = add nuw nsw i32 %37, 7
%72 = zext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %0, i64 %72
%74 = load i8, i8* %73
%75 = tail call i32 @SwapDecimalNibble(i8 zeroext %74)
%76 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 5
store i32 %75, i32* %76
%77 = add nuw nsw i32 %37, 8
%78 = zext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %0, i64 %78
%80 = load i8, i8* %79
%81 = tail call i32 @SwapDecimalNibble(i8 zeroext %80)
%82 = call i64 @mktime(%struct.tm* %10)
%83 = shl i32 %81, 24
%84 = ashr exact i32 %83, 24
%85 = mul nsw i32 %84, 900
%86 = sext i32 %85 to i64
%87 = sub nsw i64 %82, %86
store i64 %87, i64* %2
%88 = add nuw nsw i32 %37, 10
%89 = icmp ugt i32 %88, %1
br i1 %89, label %118, label %90
90: ; preds = %29
%91 = add nuw nsw i32 %37, 9
%92 = zext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %0, i64 %92
%94 = load i8, i8* %93
%95 = zext i8 %94 to i32
%96 = icmp sgt i32 %95, %6
br i1 %96, label %118, label %97
97: ; preds = %90
%98 = add nuw nsw i32 %37, 1
%99 = zext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %0, i64 %99
%101 = load i8, i8* %100
%102 = zext i8 %101 to i32
store i32 %102, i32* %7
switch i8 %101, label %111 [
i8 0, label %103
i8 8, label %108
]
103: ; preds = %97
%104 = getelementptr inbounds i8, i8* %93, i64 1
%105 = sub nsw i32 %1, %88
%106 = tail call i32 @DecodePDUMessage_GSM_7bit(i8* %104, i32 %105, i8* %5, i32 %95)
%107 = icmp eq i32 %106, %95
br i1 %107, label %111, label %118
108: ; preds = %97
%109 = getelementptr inbounds i8, i8* %93, i64 1
%110 = tail call i32 @memcpy(i8* %5, i8* %109, i32 %95)
br label %111
111: ; preds = %97, %103, %108
%112 = icmp slt i32 %95, %6
%113 = zext i8 %94 to i64
%114 = add nsw i32 %6, -1
%115 = sext i32 %114 to i64
%116 = select i1 %112, i64 %113, i64 %115
%117 = getelementptr inbounds i8, i8* %5, i64 %116
store i8 0, i8* %117
br label %118
118: ; preds = %111, %90, %103, %29
%119 = phi i32 [ -1, %29 ], [ -1, %90 ], [ -1, %103 ], [ %95, %111 ]
br label %120
120: ; preds = %12, %17, %118, %9
%121 = phi i32 [ -1, %9 ], [ -2, %12 ], [ %119, %118 ], [ -3, %17 ]
ret i32 %121
}