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

/* Variables and functions */
int /*<<< orphan*/ dyn_strcat(struct dyn_string_str *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
void comment_var(long i0_pos, char sp0, long i1_pos, char sp1, char o_sp1,
                 char sim_char, const char *ann_comment,
                 struct dyn_string_str *annot_var_dyn, int target, int d_type) {
  char tmp_str[4096], tc, ann_ch0, ann_ch1;
  char *d1_fmt;
  if (d_type == 1) {
    if (target == 1) {
      d1_fmt = " Variant: %d%c%c%d%c : %c%d%c";
      sprintf(tmp_str, d1_fmt, i0_pos + 1, sp0, sim_char, i1_pos + 1, sp1,
              o_sp1, (target ? i1_pos + 1 : i0_pos + 1), sp1);
    } else {
      d1_fmt = " qVariant: %d%c%c%d%c : %c%d%c";
      sprintf(tmp_str, d1_fmt, i0_pos + 1, sp0, sim_char, i1_pos + 1, sp1,
              o_sp1, (target ? i1_pos + 1 : i0_pos + 1), sp0);
    }
    dyn_strcat(annot_var_dyn, tmp_str);
    if (ann_comment) {
      sprintf(tmp_str, " : %s", ann_comment);
      dyn_strcat(annot_var_dyn, tmp_str);
    }
    dyn_strcat(annot_var_dyn, "\n");
  } else if (d_type == 2) {
    if (target == 1) {
      ann_ch0 = 'X';
      ann_ch1 = 'V';
    } else {
      ann_ch0 = 'V';
      ann_ch1 = 'X';
    }
    sprintf(tmp_str, "|%c%c:%ld%c%c%ld%c", ann_ch0, ann_ch1, i0_pos + 1, sp0,
            sim_char, i1_pos + 1, sp1);
    dyn_strcat(annot_var_dyn, tmp_str);
  }
}


x86 assembly (clang, -O0):
<comment_var>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x10e8,%rsp
mov    %r8d,-0x1058(%rbp)
mov    %ecx,%eax
mov    -0x1058(%rbp),%ecx
mov    %eax,-0x1054(%rbp)
mov    %rdx,%rax
mov    -0x1054(%rbp),%edx
mov    %rax,-0x1050(%rbp)
mov    %esi,%eax
mov    -0x1050(%rbp),%rsi
mov    %eax,-0x1044(%rbp)
mov    %rdi,%r8
mov    -0x1044(%rbp),%edi
mov    %r9b,%al
mov    0x28(%rbp),%r9d
mov    0x20(%rbp),%r9d
mov    0x18(%rbp),%r9
mov    0x10(%rbp),%r9
mov    %r8,-0x10(%rbp)
mov    %dil,-0x11(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %dl,-0x21(%rbp)
mov    %cl,-0x22(%rbp)
mov    %al,-0x23(%rbp)
cmpl   $0x1,0x28(%rbp)
jne    13ef <comment_var+0x2cf>
cmpl   $0x1,0x20(%rbp)
jne    12a0 <comment_var+0x180>
lea    0xe54(%rip),%rax
mov    %rax,-0x1040(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x1088(%rbp)
mov    -0x1040(%rbp),%rax
mov    %rax,-0x1080(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1078(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x1070(%rbp)
movsbl -0x23(%rbp),%eax
mov    %eax,-0x106c(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1068(%rbp)
movsbl -0x21(%rbp),%eax
mov    %eax,-0x1060(%rbp)
movsbl -0x22(%rbp),%eax
mov    %eax,-0x105c(%rbp)
cmpl   $0x0,0x20(%rbp)
je     1233 <comment_var+0x113>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1090(%rbp)
jmp    1242 <comment_var+0x122>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1090(%rbp)
mov    -0x105c(%rbp),%r11d
mov    -0x1060(%rbp),%ebx
mov    -0x1068(%rbp),%r9
mov    -0x106c(%rbp),%r8d
mov    -0x1070(%rbp),%ecx
mov    -0x1078(%rbp),%rdx
mov    -0x1080(%rbp),%rsi
mov    -0x1088(%rbp),%rdi
mov    -0x1090(%rbp),%r10
movsbl -0x21(%rbp),%eax
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1396 <comment_var+0x276>
lea    0xd77(%rip),%rax
mov    %rax,-0x1040(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x10c0(%rbp)
mov    -0x1040(%rbp),%rax
mov    %rax,-0x10b8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10b0(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x10a8(%rbp)
movsbl -0x23(%rbp),%eax
mov    %eax,-0x10a4(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10a0(%rbp)
movsbl -0x21(%rbp),%eax
mov    %eax,-0x1098(%rbp)
movsbl -0x22(%rbp),%eax
mov    %eax,-0x1094(%rbp)
cmpl   $0x0,0x20(%rbp)
je     132e <comment_var+0x20e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10c8(%rbp)
jmp    133d <comment_var+0x21d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10c8(%rbp)
mov    -0x1094(%rbp),%r11d
mov    -0x1098(%rbp),%ebx
mov    -0x10a0(%rbp),%r9
mov    -0x10a4(%rbp),%r8d
mov    -0x10a8(%rbp),%ecx
mov    -0x10b0(%rbp),%rdx
mov    -0x10b8(%rbp),%rsi
mov    -0x10c0(%rbp),%rdi
mov    -0x10c8(%rbp),%r10
movsbl -0x11(%rbp),%eax
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    0x18(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
call   1030 <dyn_strcat@plt>
cmpq   $0x0,0x10(%rbp)
je     13da <comment_var+0x2ba>
lea    -0x1030(%rbp),%rdi
mov    0x10(%rbp),%rdx
lea    0xc7a(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    0x18(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
call   1030 <dyn_strcat@plt>
mov    0x18(%rbp),%rdi
lea    0xc5e(%rip),%rsi
call   1030 <dyn_strcat@plt>
jmp    1487 <comment_var+0x367>
cmpl   $0x2,0x28(%rbp)
jne    1482 <comment_var+0x362>
cmpl   $0x1,0x20(%rbp)
jne    1416 <comment_var+0x2f6>
movb   $0x58,-0x1032(%rbp)
movb   $0x56,-0x1033(%rbp)
jmp    1424 <comment_var+0x304>
movb   $0x56,-0x1032(%rbp)
movb   $0x58,-0x1033(%rbp)
lea    -0x1030(%rbp),%rdi
movsbl -0x1032(%rbp),%edx
movsbl -0x1033(%rbp),%ecx
mov    -0x10(%rbp),%r8
add    $0x1,%r8
movsbl -0x11(%rbp),%r9d
movsbl -0x23(%rbp),%r11d
mov    -0x20(%rbp),%r10
add    $0x1,%r10
movsbl -0x21(%rbp),%eax
lea    0xbe7(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    0x18(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
call   1030 <dyn_strcat@plt>
jmp    1487 <comment_var+0x367>
add    $0x10e8,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<comment_var>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %rdx,%rbx
mov    %rdi,%rax
mov    0x1058(%rsp),%edi
mov    0x1050(%rsp),%ebp
mov    0x1048(%rsp),%r14
cmp    $0x2,%edi
je     11a4 <comment_var+0x84>
cmp    $0x1,%edi
jne    1278 <comment_var+0x158>
mov    0x1040(%rsp),%r15
add    $0x1,%rax
add    $0x1,%rbx
movsbl %sil,%r10d
movsbl %r9b,%r9d
movsbl %cl,%r11d
movsbl %r8b,%r12d
cmp    $0x1,%ebp
jne    1205 <comment_var+0xe5>
lea    0xe75(%rip),%rsi
mov    %rsp,%rdi
mov    %rax,%rdx
mov    %r10d,%ecx
mov    %r9d,%r8d
mov    %rbx,%r9
xor    %eax,%eax
push   %r11
push   %rbx
jmp    122a <comment_var+0x10a>
xor    %edi,%edi
xor    %edx,%edx
cmp    $0x1,%ebp
setne  %dil
sete   %dl
add    %edx,%edx
add    $0x56,%edx
lea    (%rdi,%rdi,1),%r8d
add    $0x56,%r8d
add    $0x1,%rax
movsbl %sil,%r10d
movsbl %r9b,%r11d
add    $0x1,%rbx
movsbl %cl,%ebp
sub    $0x8,%rsp
lea    0xe68(%rip),%rsi
lea    0x8(%rsp),%r15
mov    %r15,%rdi
mov    %r8d,%ecx
mov    %rax,%r8
mov    %r10d,%r9d
xor    %eax,%eax
push   %rbp
push   %rbx
push   %r11
call   1040 <sprintf@plt>
add    $0x20,%rsp
mov    %r14,%rdi
mov    %r15,%rsi
jmp    1273 <comment_var+0x153>
test   %ebp,%ebp
mov    %rbx,%r13
cmove  %rax,%r13
lea    0xe09(%rip),%rsi
mov    %rsp,%rdi
mov    %rax,%rdx
mov    %r10d,%ecx
mov    %r9d,%r8d
mov    %rbx,%r9
xor    %eax,%eax
push   %r10
push   %r13
push   %r12
push   %r11
call   1040 <sprintf@plt>
add    $0x20,%rsp
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <dyn_strcat@plt>
test   %r15,%r15
je     1269 <comment_var+0x149>
lea    0xdef(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <dyn_strcat@plt>
lea    0xdd3(%rip),%rsi
mov    %r14,%rdi
call   1030 <dyn_strcat@plt>
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.dyn_string_str = type { i32 }
@.str = [30 x i8] c" Variant: %d%c%c%d%c : %c%d%c\00"
@.str.1 = [31 x i8] c" qVariant: %d%c%c%d%c : %c%d%c\00"
@.str.2 = [6 x i8] c" : %s\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [19 x i8] c"|%c%c:%ld%c%c%ld%c\00"
define void @comment_var(i64 %0, i8 signext %1, i64 %2, i8 signext %3, i8 signext %4, i8 signext %5, i8* %6, %struct.dyn_string_str* %7, i32 %8, i32 %9) {
%11 = alloca [4096 x i8]
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
switch i32 %9, label %46 [
i32 1, label %13
i32 2, label %35
]
13: ; preds = %10
%14 = icmp eq i32 %8, 1
%15 = add nsw i64 %0, 1
%16 = sext i8 %1 to i32
%17 = sext i8 %5 to i32
%18 = add nsw i64 %2, 1
%19 = sext i8 %3 to i32
%20 = sext i8 %4 to i32
br i1 %14, label %21, label %23
21: ; preds = %13
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 %15, i32 %16, i32 %17, i64 %18, i32 %19, i32 %20, i64 %18, i32 %19)
br label %27
23: ; preds = %13
%24 = icmp eq i32 %8, 0
%25 = select i1 %24, i64 %15, i64 %18
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i64 %15, i32 %16, i32 %17, i64 %18, i32 %19, i32 %20, i64 %25, i32 %16)
br label %27
27: ; preds = %23, %21
%28 = call i32 @dyn_strcat(%struct.dyn_string_str* %7, i8* %12)
%29 = icmp eq i8* %6, null
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%32 = call i32 @dyn_strcat(%struct.dyn_string_str* %7, i8* %12)
br label %33
33: ; preds = %30, %27
%34 = call i32 @dyn_strcat(%struct.dyn_string_str* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %46
35: ; preds = %10
%36 = icmp eq i32 %8, 1
%37 = select i1 %36, i32 88, i32 86
%38 = select i1 %36, i32 86, i32 88
%39 = add nsw i64 %0, 1
%40 = sext i8 %1 to i32
%41 = sext i8 %5 to i32
%42 = add nsw i64 %2, 1
%43 = sext i8 %3 to i32
%44 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %37, i32 %38, i64 %39, i32 %40, i32 %41, i64 %42, i32 %43)
%45 = call i32 @dyn_strcat(%struct.dyn_string_str* %7, i8* %12)
br label %46
46: ; preds = %10, %35, %33
ret void
}