#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 /*<<< orphan*/ values;
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ *ber_decode_string_alloc(int /*<<< orphan*/ *, char **, int);
int /*<<< orphan*/ *ber_decode_string_buffer(int /*<<< orphan*/ *,
                                             char const **, int,
                                             int /*<<< orphan*/ *);
int /*<<< orphan*/ *ber_decode_string_len_buffer(int /*<<< orphan*/ *,
                                                 char const **, int *);
int /*<<< orphan*/ *ber_encode_string(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ *ber_encode_string_len(int /*<<< orphan*/ *, char const *,
                                          scalar_t__);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ hexdump(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strlen(char const *);
scalar_t__ strncmp(char const *, char const *, int);
void ber_string_test(uint8_t *buf, uint8_t *buf_end) {
  uint8_t *enc_out, *dec_out;
  const char *values[] = {"a", "ab", "test123", "testing_longer_name"};
  const char *str;
  char *astr;
  uint8_t next;
  uint32_t i, enc_method, str_len;
  printf("# Testing BER string coding\n");
  for (i = 0; i < sizeof(values) / sizeof(values[0]); ++i) {
    printf("ber_encode_string(\"%s\")", values[i]);
    for (enc_method = 0; enc_method < 2; ++enc_method) {
      if (enc_method == 0) {
        enc_out = ber_encode_string(buf_end, values[i]);
      } else {
        enc_out = ber_encode_string_len(buf_end, values[i], strlen(values[i]));
      }
      dec_out = ber_decode_string_len_buffer(enc_out + 1, &str, &str_len);
      assert(str_len == strlen(values[i]));
      assert(strncmp(str, values[i], str_len) == 0);
      assert(dec_out == buf_end + 1);
      dec_out = ber_decode_string_alloc(enc_out + 1, &astr, 128);
      assert(strlen(astr) == strlen(values[i]));
      assert(strncmp(str, values[i], str_len) == 0);
      assert(dec_out == buf_end + 1);
      free(astr);
      dec_out = ber_decode_string_buffer(enc_out + 1, &str, 128, &next);
      assert(strlen(str) == strlen(values[i]));
      assert(strncmp(str, values[i], str_len) == 0);
      assert(dec_out == buf_end + 1);
    }
    hexdump("", enc_out + 1, buf_end - enc_out);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<ber_string_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2c36(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c33(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c30(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c2d(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x58(%rbp)
movslq -0x58(%rbp),%rax
cmp    $0x4,%rax
jae    148e <ber_string_test+0x2de>
movslq -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x2,-0x5c(%rbp)
jge    145b <ber_string_test+0x2ab>
cmpl   $0x0,-0x5c(%rbp)
jne    125f <ber_string_test+0xaf>
mov    -0x10(%rbp),%rdi
movslq -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
call   10d0 <ber_encode_string@plt>
mov    %rax,-0x18(%rbp)
jmp    1296 <ber_string_test+0xe6>
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
movslq -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rax
mov    %rax,-0x68(%rbp)
movslq -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1070 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    %rax,%rdx
call   1060 <ber_encode_string_len@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
lea    -0x48(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   10b0 <ber_decode_string_len_buffer@plt>
mov    %rax,-0x20(%rbp)
movslq -0x60(%rbp),%rax
mov    %rax,-0x88(%rbp)
movslq -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x48(%rbp),%rdi
movslq -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
mov    -0x60(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x4,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
lea    -0x50(%rbp),%rsi
mov    $0x80,%edx
call   1050 <ber_decode_string_alloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x50(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,-0x80(%rbp)
movslq -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x48(%rbp),%rdi
movslq -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
mov    -0x60(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x4,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
lea    -0x48(%rbp),%rsi
mov    $0x80,%edx
lea    -0x54(%rbp),%rcx
call   1090 <ber_decode_string_buffer@plt>
mov    %rax,-0x20(%rbp)
mov    -0x48(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,-0x78(%rbp)
movslq -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x48(%rbp),%rdi
movslq -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
mov    -0x60(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x4,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1230 <ber_string_test+0x80>
mov    -0x18(%rbp),%rsi
add    $0x4,%rsi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
mov    %eax,%edx
lea    0xbc2(%rip),%rdi
call   10c0 <hexdump@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1204 <ber_string_test+0x54>
lea    0xba7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ber_string_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
lea    0xe51(%rip),%rdi
call   1070 <puts@plt>
mov    %rbx,0x10(%rsp)
lea    0x4(%rbx),%rax
mov    %rax,0x30(%rsp)
xor    %ecx,%ecx
mov    0x30(%rsp),%r12
jmp    1240 <ber_string_test+0x70>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp),%rdx
sub    0x38(%rsp),%rdx
shr    $0x2,%rdx
lea    0xe13(%rip),%rdi
mov    %r13,%rsi
call   10e0 <hexdump@plt>
mov    0x28(%rsp),%rcx
add    $0x1,%rcx
cmp    $0x4,%rcx
je     13f5 <ber_string_test+0x225>
lea    0x2bb9(%rip),%rax
mov    %rcx,0x28(%rsp)
mov    (%rax,%rcx,8),%r14
lea    0xdca(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x1,%al
jmp    13d7 <ber_string_test+0x207>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1090 <strlen@plt>
mov    0x10(%rsp),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1080 <ber_encode_string_len@plt>
mov    %rax,0x38(%rsp)
lea    0x4(%rax),%r13
mov    %r13,%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   10d0 <ber_decode_string_len_buffer@plt>
mov    %rax,%rbp
movslq 0x4(%rsp),%rbx
mov    %r14,%rdi
call   1090 <strlen@plt>
xor    %edi,%edi
cmp    %rbx,%rax
sete   %dil
call   10c0 <assert@plt>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%edx
mov    %r14,%rsi
call   1050 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   10c0 <assert@plt>
xor    %edi,%edi
cmp    %r12,%rbp
sete   %dil
call   10c0 <assert@plt>
mov    %r13,%rdi
lea    0x20(%rsp),%rsi
mov    $0x80,%edx
call   1060 <ber_decode_string_alloc@plt>
mov    %rax,%rbp
mov    0x20(%rsp),%rdi
call   1090 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1090 <strlen@plt>
xor    %edi,%edi
cmp    %rax,%r15
sete   %dil
call   10c0 <assert@plt>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%edx
mov    %r14,%rsi
call   1050 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   10c0 <assert@plt>
xor    %edi,%edi
cmp    %r12,%rbp
sete   %dil
call   10c0 <assert@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
lea    0x8(%rsp),%rsi
mov    $0x80,%edx
lea    0x44(%rsp),%rcx
call   10b0 <ber_decode_string_buffer@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%rdi
call   1090 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1090 <strlen@plt>
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   10c0 <assert@plt>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%edx
mov    %r14,%rsi
call   1050 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   10c0 <assert@plt>
xor    %edi,%edi
cmp    %r12,%rbp
sete   %dil
call   10c0 <assert@plt>
testb  $0x1,0x1c(%rsp)
mov    $0x0,%eax
je     1210 <ber_string_test+0x40>
test   $0x1,%al
mov    %eax,0x1c(%rsp)
je     1270 <ber_string_test+0xa0>
mov    0x10(%rsp),%rdi
mov    %r14,%rsi
call   10f0 <ber_encode_string@plt>
jmp    1288 <ber_string_test+0xb8>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@.str.1 = [3 x i8] c"ab\00"
@.str.2 = [8 x i8] c"test123\00"
@.str.3 = [20 x i8] c"testing_longer_name\00"
@__const.ber_string_test.values = [4 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [29 x i8] c"# Testing BER string coding\0A\00"
@.str.5 = [24 x i8] c"ber_encode_string(\22%s\22)\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [2 x i8] c"\0A\00"
define void @ber_string_test(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [4 x i8*]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%14 = bitcast [4 x i8*]* %7 to i8*
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %11
br label %16
16: ; preds = %155, %2
%17 = load i32, i32* %11
%18 = sext i32 %17 to i64
%19 = icmp ult i64 %18, 4
br i1 %19, label %20, label %158
20: ; preds = %16
%21 = load i32, i32* %11
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %24)
store i32 0, i32* %12
br label %26
26: ; preds = %141, %20
%27 = load i32, i32* %12
%28 = icmp slt i32 %27, 2
br i1 %28, label %29, label %144
29: ; preds = %26
%30 = load i32, i32* %12
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32*, i32** %4
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %35
%37 = load i8*, i8** %36
%38 = call i32* @ber_encode_string(i32* %33, i8* %37)
store i32* %38, i32** %5
br label %51
39: ; preds = %29
%40 = load i32*, i32** %4
%41 = load i32, i32* %11
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %42
%44 = load i8*, i8** %43
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %46
%48 = load i8*, i8** %47
%49 = call i64 @strlen(i8* %48)
%50 = call i32* @ber_encode_string_len(i32* %40, i8* %44, i64 %49)
store i32* %50, i32** %5
br label %51
51: ; preds = %39, %32
%52 = load i32*, i32** %5
%53 = getelementptr inbounds i32, i32* %52, i64 1
%54 = call i32* @ber_decode_string_len_buffer(i32* %53, i8** %8, i32* %13)
store i32* %54, i32** %6
%55 = load i32, i32* %13
%56 = sext i32 %55 to i64
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %58
%60 = load i8*, i8** %59
%61 = call i64 @strlen(i8* %60)
%62 = icmp eq i64 %56, %61
%63 = zext i1 %62 to i32
%64 = call i32 @assert(i32 %63)
%65 = load i8*, i8** %8
%66 = load i32, i32* %11
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %67
%69 = load i8*, i8** %68
%70 = load i32, i32* %13
%71 = call i64 @strncmp(i8* %65, i8* %69, i32 %70)
%72 = icmp eq i64 %71, 0
%73 = zext i1 %72 to i32
%74 = call i32 @assert(i32 %73)
%75 = load i32*, i32** %6
%76 = load i32*, i32** %4
%77 = getelementptr inbounds i32, i32* %76, i64 1
%78 = icmp eq i32* %75, %77
%79 = zext i1 %78 to i32
%80 = call i32 @assert(i32 %79)
%81 = load i32*, i32** %5
%82 = getelementptr inbounds i32, i32* %81, i64 1
%83 = call i32* @ber_decode_string_alloc(i32* %82, i8** %9, i32 128)
store i32* %83, i32** %6
%84 = load i8*, i8** %9
%85 = call i64 @strlen(i8* %84)
%86 = load i32, i32* %11
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %87
%89 = load i8*, i8** %88
%90 = call i64 @strlen(i8* %89)
%91 = icmp eq i64 %85, %90
%92 = zext i1 %91 to i32
%93 = call i32 @assert(i32 %92)
%94 = load i8*, i8** %8
%95 = load i32, i32* %11
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %96
%98 = load i8*, i8** %97
%99 = load i32, i32* %13
%100 = call i64 @strncmp(i8* %94, i8* %98, i32 %99)
%101 = icmp eq i64 %100, 0
%102 = zext i1 %101 to i32
%103 = call i32 @assert(i32 %102)
%104 = load i32*, i32** %6
%105 = load i32*, i32** %4
%106 = getelementptr inbounds i32, i32* %105, i64 1
%107 = icmp eq i32* %104, %106
%108 = zext i1 %107 to i32
%109 = call i32 @assert(i32 %108)
%110 = load i8*, i8** %9
%111 = call i32 @free(i8* %110)
%112 = load i32*, i32** %5
%113 = getelementptr inbounds i32, i32* %112, i64 1
%114 = call i32* @ber_decode_string_buffer(i32* %113, i8** %8, i32 128, i32* %10)
store i32* %114, i32** %6
%115 = load i8*, i8** %8
%116 = call i64 @strlen(i8* %115)
%117 = load i32, i32* %11
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %118
%120 = load i8*, i8** %119
%121 = call i64 @strlen(i8* %120)
%122 = icmp eq i64 %116, %121
%123 = zext i1 %122 to i32
%124 = call i32 @assert(i32 %123)
%125 = load i8*, i8** %8
%126 = load i32, i32* %11
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %127
%129 = load i8*, i8** %128
%130 = load i32, i32* %13
%131 = call i64 @strncmp(i8* %125, i8* %129, i32 %130)
%132 = icmp eq i64 %131, 0
%133 = zext i1 %132 to i32
%134 = call i32 @assert(i32 %133)
%135 = load i32*, i32** %6
%136 = load i32*, i32** %4
%137 = getelementptr inbounds i32, i32* %136, i64 1
%138 = icmp eq i32* %135, %137
%139 = zext i1 %138 to i32
%140 = call i32 @assert(i32 %139)
br label %141
141: ; preds = %51
%142 = load i32, i32* %12
%143 = add nsw i32 %142, 1
store i32 %143, i32* %12
br label %26
144: ; preds = %26
%145 = load i32*, i32** %5
%146 = getelementptr inbounds i32, i32* %145, i64 1
%147 = load i32*, i32** %4
%148 = load i32*, i32** %5
%149 = ptrtoint i32* %147 to i64
%150 = ptrtoint i32* %148 to i64
%151 = sub i64 %149, %150
%152 = sdiv exact i64 %151, 4
%153 = trunc i64 %152 to i32
%154 = call i32 @hexdump(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i32* %146, i32 %153)
br label %155
155: ; preds = %144
%156 = load i32, i32* %11
%157 = add nsw i32 %156, 1
store i32 %157, i32* %11
br label %16
158: ; preds = %16
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@.str.1 = [3 x i8] c"ab\00"
@.str.2 = [8 x i8] c"test123\00"
@.str.3 = [20 x i8] c"testing_longer_name\00"
@__const.ber_string_test.values = [4 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i32 0, i32 0)]
@.str.5 = [24 x i8] c"ber_encode_string(\22%s\22)\00"
@.str.6 = [1 x i8] zeroinitializer
@str = [28 x i8] c"# Testing BER string coding\00"
define void @ber_string_test(i32* nocapture readnone %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i8** %3 to i8*
%8 = bitcast i8** %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%12 = getelementptr inbounds i32, i32* %1, i64 1
%13 = ptrtoint i32* %1 to i64
br label %14
14: ; preds = %2, %79
%15 = phi i64 [ 0, %2 ], [ %85, %79 ]
%16 = getelementptr inbounds [4 x i8*], [4 x i8*]* @__const.ber_string_test.values, i64 0, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %14, %26
%20 = phi i1 [ true, %14 ], [ false, %26 ]
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = call i32* @ber_encode_string(i32* %1, i8* %17)
br label %26
23: ; preds = %19
%24 = call i64 @strlen(i8* dereferenceable(1) %17)
%25 = call i32* @ber_encode_string_len(i32* %1, i8* %17, i64 %24)
br label %26
26: ; preds = %23, %21
%27 = phi i32* [ %22, %21 ], [ %25, %23 ]
%28 = getelementptr inbounds i32, i32* %27, i64 1
%29 = call i32* @ber_decode_string_len_buffer(i32* %28, i8** %3, i32* %6)
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = call i64 @strlen(i8* dereferenceable(1) %17)
%33 = icmp eq i64 %32, %31
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i8*, i8** %3
%37 = load i32, i32* %6
%38 = call i64 @strncmp(i8* %36, i8* %17, i32 %37)
%39 = icmp eq i64 %38, 0
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = icmp eq i32* %29, %12
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = call i32* @ber_decode_string_alloc(i32* %28, i8** %4, i32 128)
%46 = load i8*, i8** %4
%47 = call i64 @strlen(i8* dereferenceable(1) %46)
%48 = call i64 @strlen(i8* dereferenceable(1) %17)
%49 = icmp eq i64 %47, %48
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
%52 = load i8*, i8** %3
%53 = load i32, i32* %6
%54 = call i64 @strncmp(i8* %52, i8* %17, i32 %53)
%55 = icmp eq i64 %54, 0
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = icmp eq i32* %45, %12
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
%61 = load i8*, i8** %4
%62 = call i32 @free(i8* %61)
%63 = call i32* @ber_decode_string_buffer(i32* %28, i8** %3, i32 128, i32* %5)
%64 = load i8*, i8** %3
%65 = call i64 @strlen(i8* dereferenceable(1) %64)
%66 = call i64 @strlen(i8* dereferenceable(1) %17)
%67 = icmp eq i64 %65, %66
%68 = zext i1 %67 to i32
%69 = call i32 @assert(i32 %68)
%70 = load i8*, i8** %3
%71 = load i32, i32* %6
%72 = call i64 @strncmp(i8* %70, i8* %17, i32 %71)
%73 = icmp eq i64 %72, 0
%74 = zext i1 %73 to i32
%75 = call i32 @assert(i32 %74)
%76 = icmp eq i32* %63, %12
%77 = zext i1 %76 to i32
%78 = call i32 @assert(i32 %77)
br i1 %20, label %19, label %79
79: ; preds = %26
%80 = ptrtoint i32* %27 to i64
%81 = sub i64 %13, %80
%82 = lshr exact i64 %81, 2
%83 = trunc i64 %82 to i32
%84 = call i32 @hexdump(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i32* %28, i32 %83)
%85 = add nuw nsw i64 %15, 1
%86 = icmp eq i64 %85, 4
br i1 %86, label %87, label %14
87: ; preds = %79
%88 = call i32 @putchar(i32 10)
ret void
}