#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 gg_session {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ gg_debug_session(struct gg_session *, int, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
void gg_debug_dump(struct gg_session *gs, int level, const char *buf,
                   size_t len) {
  char line[80];
  unsigned int i, j;
  for (i = 0; i < len; i += 16) {
    int ofs;
    sprintf(line, "%.4x: ", i);
    ofs = 6;
    for (j = 0; j < 16; j++) {
      if (i + j < len)
        sprintf(line + ofs, " %02x", (unsigned char)buf[i + j]);
      else
        sprintf(line + ofs, "   ");
      ofs += 3;
    }
    sprintf(line + ofs, "  ");
    ofs += 2;
    for (j = 0; j < 16; j++) {
      unsigned char ch;
      if (i + j < len) {
        ch = buf[i + j];
        if (ch < 32 || ch > 126)
          ch = '.';
      } else {
        ch = ' ';
      }
      line[ofs++] = ch;
    }
    line[ofs++] = '\n';
    line[ofs++] = 0;
    gg_debug_session(gs, level, "%s", line);
  }
}


x86 assembly (clang, -O0):
<gg_debug_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x20(%rbp),%rax
jae    12d4 <gg_debug_dump+0x1b4>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%edx
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
movl   $0x6,-0x7c(%rbp)
movl   $0x0,-0x78(%rbp)
cmpl   $0x10,-0x78(%rbp)
jae    11eb <gg_debug_dump+0xcb>
mov    -0x74(%rbp),%eax
add    -0x78(%rbp),%eax
mov    %eax,%eax
cmp    -0x20(%rbp),%rax
jae    11bb <gg_debug_dump+0x9b>
lea    -0x70(%rbp),%rdi
movslq -0x7c(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rax
mov    -0x74(%rbp),%ecx
add    -0x78(%rbp),%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xe58(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11d4 <gg_debug_dump+0xb4>
lea    -0x70(%rbp),%rdi
movslq -0x7c(%rbp),%rax
add    %rax,%rdi
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x7c(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x7c(%rbp)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1171 <gg_debug_dump+0x51>
lea    -0x70(%rbp),%rdi
movslq -0x7c(%rbp),%rax
add    %rax,%rdi
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x7c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x7c(%rbp)
movl   $0x0,-0x78(%rbp)
cmpl   $0x10,-0x78(%rbp)
jae    128b <gg_debug_dump+0x16b>
mov    -0x74(%rbp),%eax
add    -0x78(%rbp),%eax
mov    %eax,%eax
cmp    -0x20(%rbp),%rax
jae    1265 <gg_debug_dump+0x145>
mov    -0x18(%rbp),%rax
mov    -0x74(%rbp),%ecx
add    -0x78(%rbp),%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x7d(%rbp)
movzbl -0x7d(%rbp),%eax
cmp    $0x20,%eax
jl     125c <gg_debug_dump+0x13c>
movzbl -0x7d(%rbp),%eax
cmp    $0x7e,%eax
jle    1260 <gg_debug_dump+0x140>
movb   $0x2e,-0x7d(%rbp)
jmp    1269 <gg_debug_dump+0x149>
movb   $0x20,-0x7d(%rbp)
mov    -0x7d(%rbp),%cl
mov    -0x7c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x7c(%rbp)
cltq
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1214 <gg_debug_dump+0xf4>
mov    -0x7c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x7c(%rbp)
cltq
movb   $0xa,-0x70(%rbp,%rax,1)
mov    -0x7c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x7c(%rbp)
cltq
movb   $0x0,-0x70(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x70(%rbp),%rcx
lea    0xd50(%rip),%rdx
call   1030 <gg_debug_session@plt>
mov    -0x74(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x74(%rbp)
jmp    1141 <gg_debug_dump+0x21>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gg_debug_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %esi,0xc(%rsp)
mov    %rdi,0x10(%rsp)
test   %rcx,%rcx
je     1261 <gg_debug_dump+0x141>
mov    %rcx,%rbx
mov    %rdx,%r14
lea    0x20(%rsp),%rbp
lea    0xeb5(%rip),%r12
mov    $0x2e,%r15d
xor    %edx,%edx
jmp    118c <gg_debug_dump+0x6c>
nopl   0x0(%rax)
movw   $0xa,0x68(%rsp)
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
lea    0xe99(%rip),%rdx
mov    %rbp,%rcx
call   1030 <gg_debug_session@plt>
lea    0x10(%r13),%edx
cmp    %rbx,%rdx
jae    1261 <gg_debug_dump+0x141>
mov    %edx,%r13d
mov    %rbp,%rdi
lea    0xe67(%rip),%rsi
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    $0x6,%ebp
mov    %r13,0x18(%rsp)
jmp    11c6 <gg_debug_dump+0xa6>
nopl   0x0(%rax)
movl   $0x202020,0x20(%rsp,%rbp,1)
add    $0x3,%rbp
add    $0x1,%r13
cmp    $0x36,%rbp
je     11f0 <gg_debug_dump+0xd0>
cmp    %rbx,%r13
jae    11b0 <gg_debug_dump+0x90>
lea    (%rsp,%rbp,1),%rdi
add    $0x20,%rdi
movzbl (%r14,%r13,1),%edx
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    11b8 <gg_debug_dump+0x98>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x56(%rsp),%rax
movb   $0x0,0x2(%rax)
movw   $0x2020,(%rax)
mov    0x18(%rsp),%r13
mov    %r13,%rax
xor    %ecx,%ecx
lea    0x20(%rsp),%rbp
jmp    1226 <gg_debug_dump+0x106>
nop
mov    %dl,0x59(%rsp,%rcx,1)
add    $0x2,%rcx
add    $0x2,%rax
cmp    $0x10,%rcx
je     1160 <gg_debug_dump+0x40>
mov    $0x20,%dl
mov    $0x20,%sil
cmp    %rbx,%rax
jae    1240 <gg_debug_dump+0x120>
movzbl (%r14,%rax,1),%esi
lea    -0x7f(%rsi),%edi
cmp    $0xa1,%dil
cmovb  %r15d,%esi
mov    %sil,0x58(%rsp,%rcx,1)
lea    0x1(%rax),%rsi
cmp    %rbx,%rsi
jae    1210 <gg_debug_dump+0xf0>
movzbl 0x1(%r14,%rax,1),%edx
lea    -0x7f(%rdx),%esi
cmp    $0xa1,%sil
cmovb  %r15d,%edx
jmp    1210 <gg_debug_dump+0xf0>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.gg_session = type { i32 }
@.str = [7 x i8] c"%.4x: \00"
@.str.1 = [6 x i8] c" %02x\00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [3 x i8] c" \00"
@.str.4 = [3 x i8] c"%s\00"
define void @gg_debug_dump(%struct.gg_session* %0, i32 %1, i8* %2, i64 %3) {
%5 = alloca %struct.gg_session*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca [80 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
store %struct.gg_session* %0, %struct.gg_session** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
store i32 0, i32* %10
br label %14
14: ; preds = %117, %4
%15 = load i32, i32* %10
%16 = zext i32 %15 to i64
%17 = load i64, i64* %8
%18 = icmp ult i64 %16, %17
br i1 %18, label %19, label %120
19: ; preds = %14
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%21 = load i32, i32* %10
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %21)
store i32 6, i32* %12
store i32 0, i32* %11
br label %23
23: ; preds = %56, %19
%24 = load i32, i32* %11
%25 = icmp ult i32 %24, 16
br i1 %25, label %26, label %59
26: ; preds = %23
%27 = load i32, i32* %10
%28 = load i32, i32* %11
%29 = add i32 %27, %28
%30 = zext i32 %29 to i64
%31 = load i64, i64* %8
%32 = icmp ult i64 %30, %31
br i1 %32, label %33, label %47
33: ; preds = %26
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%35 = load i32, i32* %12
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8*, i8** %7
%39 = load i32, i32* %10
%40 = load i32, i32* %11
%41 = add i32 %39, %40
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %38, i64 %42
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %45)
br label %53
47: ; preds = %26
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%49 = load i32, i32* %12
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = call i32 (i8*, i8*, ...) @sprintf(i8* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %47, %33
%54 = load i32, i32* %12
%55 = add nsw i32 %54, 3
store i32 %55, i32* %12
br label %56
56: ; preds = %53
%57 = load i32, i32* %11
%58 = add i32 %57, 1
store i32 %58, i32* %11
br label %23
59: ; preds = %23
%60 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%61 = load i32, i32* %12
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = call i32 (i8*, i8*, ...) @sprintf(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%65 = load i32, i32* %12
%66 = add nsw i32 %65, 2
store i32 %66, i32* %12
store i32 0, i32* %11
br label %67
67: ; preds = %101, %59
%68 = load i32, i32* %11
%69 = icmp ult i32 %68, 16
br i1 %69, label %70, label %104
70: ; preds = %67
%71 = load i32, i32* %10
%72 = load i32, i32* %11
%73 = add i32 %71, %72
%74 = zext i32 %73 to i64
%75 = load i64, i64* %8
%76 = icmp ult i64 %74, %75
br i1 %76, label %77, label %94
77: ; preds = %70
%78 = load i8*, i8** %7
%79 = load i32, i32* %10
%80 = load i32, i32* %11
%81 = add i32 %79, %80
%82 = zext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %78, i64 %82
%84 = load i8, i8* %83
store i8 %84, i8* %13
%85 = load i8, i8* %13
%86 = zext i8 %85 to i32
%87 = icmp slt i32 %86, 32
br i1 %87, label %92, label %88
88: ; preds = %77
%89 = load i8, i8* %13
%90 = zext i8 %89 to i32
%91 = icmp sgt i32 %90, 126
br i1 %91, label %92, label %93
92: ; preds = %88, %77
store i8 46, i8* %13
br label %93
93: ; preds = %92, %88
br label %95
94: ; preds = %70
store i8 32, i8* %13
br label %95
95: ; preds = %94, %93
%96 = load i8, i8* %13
%97 = load i32, i32* %12
%98 = add nsw i32 %97, 1
store i32 %98, i32* %12
%99 = sext i32 %97 to i64
%100 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 %99
store i8 %96, i8* %100
br label %101
101: ; preds = %95
%102 = load i32, i32* %11
%103 = add i32 %102, 1
store i32 %103, i32* %11
br label %67
104: ; preds = %67
%105 = load i32, i32* %12
%106 = add nsw i32 %105, 1
store i32 %106, i32* %12
%107 = sext i32 %105 to i64
%108 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 %107
store i8 10, i8* %108
%109 = load i32, i32* %12
%110 = add nsw i32 %109, 1
store i32 %110, i32* %12
%111 = sext i32 %109 to i64
%112 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 %111
store i8 0, i8* %112
%113 = load %struct.gg_session*, %struct.gg_session** %5
%114 = load i32, i32* %6
%115 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%116 = call i32 @gg_debug_session(%struct.gg_session* %113, i32 %114, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %115)
br label %117
117: ; preds = %104
%118 = load i32, i32* %10
%119 = add i32 %118, 16
store i32 %119, i32* %10
br label %14
120: ; preds = %14
ret void
}

LLVM IR (-O2):
%struct.gg_session = type { i32 }
@.str = [7 x i8] c"%.4x: \00"
@.str.1 = [6 x i8] c" %02x\00"
@.str.3 = [3 x i8] c" \00"
@.str.4 = [3 x i8] c"%s\00"
define void @gg_debug_dump(%struct.gg_session* %0, i32 %1, i8* nocapture %2, i64 %3) {
%5 = alloca [80 x i8]
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%7 = icmp eq i64 %3, 0
br i1 %7, label %69, label %8
8: ; preds = %4
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 72
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 54
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 73
br label %12
12: ; preds = %8, %64
%13 = phi i32 [ %66, %64 ], [ 0, %8 ]
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = zext i32 %13 to i64
br label %16
16: ; preds = %12, %29
%17 = phi i64 [ 0, %12 ], [ %31, %29 ]
%18 = phi i64 [ 6, %12 ], [ %30, %29 ]
%19 = add nuw nsw i64 %17, %15
%20 = icmp ult i64 %19, %3
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %18
br i1 %20, label %22, label %27
22: ; preds = %16
%23 = getelementptr inbounds i8, i8* %2, i64 %19
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %21, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %29
27: ; preds = %16
%28 = bitcast i8* %21 to i32*
store i32 2105376, i32* %28
br label %29
29: ; preds = %27, %22
%30 = add nuw nsw i64 %18, 3
%31 = add nuw nsw i64 %17, 1
%32 = icmp eq i64 %31, 16
br i1 %32, label %33, label %16
33: ; preds = %29
br label %34
34: ; preds = %58, %33
%35 = phi i64 [ 0, %33 ], [ %62, %58 ]
%36 = phi i64 [ 56, %33 ], [ %60, %58 ]
%37 = add nuw nsw i64 %35, %15
%38 = icmp ult i64 %37, %3
br i1 %38, label %39, label %45
39: ; preds = %34
%40 = getelementptr inbounds i8, i8* %2, i64 %37
%41 = load i8, i8* %40
%42 = add i8 %41, -127
%43 = icmp ult i8 %42, -95
%44 = select i1 %43, i8 46, i8 %41
br label %45
45: ; preds = %34, %39
%46 = phi i8 [ %44, %39 ], [ 32, %34 ]
%47 = or i64 %36, 1
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %36
store i8 %46, i8* %48
%49 = or i64 %35, 1
%50 = add nuw nsw i64 %49, %15
%51 = icmp ult i64 %50, %3
br i1 %51, label %52, label %58
52: ; preds = %45
%53 = getelementptr inbounds i8, i8* %2, i64 %50
%54 = load i8, i8* %53
%55 = add i8 %54, -127
%56 = icmp ult i8 %55, -95
%57 = select i1 %56, i8 46, i8 %54
br label %58
58: ; preds = %52, %45
%59 = phi i8 [ %57, %52 ], [ 32, %45 ]
%60 = add nuw nsw i64 %36, 2
%61 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %47
store i8 %59, i8* %61
%62 = add nuw nsw i64 %35, 2
%63 = icmp eq i64 %62, 16
br i1 %63, label %64, label %34
64: ; preds = %58
store i8 10, i8* %9
store i8 0, i8* %11
%65 = call i32 @gg_debug_session(%struct.gg_session* %0, i32 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%66 = add i32 %13, 16
%67 = zext i32 %66 to i64
%68 = icmp ult i64 %67, %3
br i1 %68, label %12, label %69
69: ; preds = %64, %4
ret void
}