#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, i1_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, i1_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    $0x1078,%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    12c7 <comment_var+0x1a7>
cmpl   $0x1,0x20(%rbp)
jne    120c <comment_var+0xec>
lea    0xe54(%rip),%rax
mov    %rax,-0x1040(%rbp)
lea    -0x1030(%rbp),%rdi
mov    -0x1040(%rbp),%rsi
mov    -0x10(%rbp),%rdx
add    $0x1,%rdx
movsbl -0x11(%rbp),%ecx
movsbl -0x23(%rbp),%r8d
mov    -0x20(%rbp),%r9
add    $0x1,%r9
movsbl -0x21(%rbp),%ebx
movsbl -0x22(%rbp),%r11d
mov    -0x20(%rbp),%r10
add    $0x1,%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    126e <comment_var+0x14e>
lea    0xe0b(%rip),%rax
mov    %rax,-0x1040(%rbp)
lea    -0x1030(%rbp),%rdi
mov    -0x1040(%rbp),%rsi
mov    -0x10(%rbp),%rdx
add    $0x1,%rdx
movsbl -0x11(%rbp),%ecx
movsbl -0x23(%rbp),%r8d
mov    -0x20(%rbp),%r9
add    $0x1,%r9
movsbl -0x21(%rbp),%ebx
movsbl -0x22(%rbp),%r11d
mov    -0x20(%rbp),%r10
add    $0x1,%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     12b2 <comment_var+0x192>
lea    -0x1030(%rbp),%rdi
mov    0x10(%rbp),%rdx
lea    0xda2(%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    0xd86(%rip),%rsi
call   1030 <dyn_strcat@plt>
jmp    135f <comment_var+0x23f>
cmpl   $0x2,0x28(%rbp)
jne    135a <comment_var+0x23a>
cmpl   $0x1,0x20(%rbp)
jne    12ee <comment_var+0x1ce>
movb   $0x58,-0x1032(%rbp)
movb   $0x56,-0x1033(%rbp)
jmp    12fc <comment_var+0x1dc>
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    0xd0f(%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    135f <comment_var+0x23f>
add    $0x1078,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<comment_var>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    %rdx,%rbx
mov    %rdi,%rax
mov    0x1048(%rsp),%edi
mov    0x1040(%rsp),%ebp
mov    0x1038(%rsp),%r14
cmp    $0x2,%edi
je     119a <comment_var+0x7a>
cmp    $0x1,%edi
jne    1264 <comment_var+0x144>
mov    0x1030(%rsp),%r15
add    $0x1,%rax
add    $0x1,%rbx
movsbl %sil,%r10d
movsbl %r9b,%r9d
movsbl %cl,%r11d
movsbl %r8b,%r12d
cmp    $0x1,%ebp
jne    11fb <comment_var+0xdb>
lea    0xe7b(%rip),%rsi
mov    %rsp,%rdi
mov    %rax,%rdx
mov    %r10d,%ecx
mov    %r9d,%r8d
mov    %rbx,%r9
xor    %eax,%eax
push   %r11
jmp    1215 <comment_var+0xf5>
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    0xe72(%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    125f <comment_var+0x13f>
lea    0xe1c(%rip),%rsi
mov    %rsp,%rdi
mov    %rax,%rdx
mov    %r10d,%ecx
mov    %r9d,%r8d
mov    %rbx,%r9
xor    %eax,%eax
push   %r10
push   %rbx
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     1255 <comment_var+0x135>
lea    0xe03(%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    0xde7(%rip),%rsi
mov    %r14,%rdi
call   1030 <dyn_strcat@plt>
add    $0x1000,%rsp
pop    %rbx
pop    %r12
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 %87
28: ; preds = %10
%29 = load i32, i32* %19
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %51
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 i64, i64* %13
%47 = add nsw i64 %46, 1
%48 = load i8, i8* %14
%49 = sext i8 %48 to i32
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* %33, i64 %35, i32 %37, i32 %39, i64 %41, i32 %43, i32 %45, i64 %47, i32 %49)
br label %71
51: ; preds = %28
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8** %25
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %21, i64 0, i64 0
%53 = load i8*, i8** %25
%54 = load i64, i64* %11
%55 = add nsw i64 %54, 1
%56 = load i8, i8* %12
%57 = sext i8 %56 to i32
%58 = load i8, i8* %16
%59 = sext i8 %58 to i32
%60 = load i64, i64* %13
%61 = add nsw i64 %60, 1
%62 = load i8, i8* %14
%63 = sext i8 %62 to i32
%64 = load i8, i8* %15
%65 = sext i8 %64 to i32
%66 = load i64, i64* %13
%67 = add nsw i64 %66, 1
%68 = load i8, i8* %12
%69 = sext i8 %68 to i32
%70 = call i32 (i8*, i8*, ...) @sprintf(i8* %52, i8* %53, i64 %55, i32 %57, i32 %59, i64 %61, i32 %63, i32 %65, i64 %67, i32 %69)
br label %71
71: ; preds = %51, %31
%72 = load %struct.dyn_string_str*, %struct.dyn_string_str** %18
%73 = getelementptr inbounds [4096 x i8], [4096 x i8]* %21, i64 0, i64 0
%74 = call i32 @dyn_strcat(%struct.dyn_string_str* %72, i8* %73)
%75 = load i8*, i8** %17
%76 = icmp ne i8* %75, null
br i1 %76, label %77, label %84
77: ; preds = %71
%78 = getelementptr inbounds [4096 x i8], [4096 x i8]* %21, i64 0, i64 0
%79 = load i8*, i8** %17
%80 = call i32 (i8*, i8*, ...) @sprintf(i8* %78, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %79)
%81 = load %struct.dyn_string_str*, %struct.dyn_string_str** %18
%82 = getelementptr inbounds [4096 x i8], [4096 x i8]* %21, i64 0, i64 0
%83 = call i32 @dyn_strcat(%struct.dyn_string_str* %81, i8* %82)
br label %84
84: ; preds = %77, %71
%85 = load %struct.dyn_string_str*, %struct.dyn_string_str** %18
%86 = call i32 @dyn_strcat(%struct.dyn_string_str* %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %116
87: ; preds = %10
%88 = load i32, i32* %20
%89 = icmp eq i32 %88, 2
br i1 %89, label %90, label %115
90: ; preds = %87
%91 = load i32, i32* %19
%92 = icmp eq i32 %91, 1
br i1 %92, label %93, label %94
93: ; preds = %90
store i8 88, i8* %23
store i8 86, i8* %24
br label %95
94: ; preds = %90
store i8 86, i8* %23
store i8 88, i8* %24
br label %95
95: ; preds = %94, %93
%96 = getelementptr inbounds [4096 x i8], [4096 x i8]* %21, i64 0, i64 0
%97 = load i8, i8* %23
%98 = sext i8 %97 to i32
%99 = load i8, i8* %24
%100 = sext i8 %99 to i32
%101 = load i64, i64* %11
%102 = add nsw i64 %101, 1
%103 = load i8, i8* %12
%104 = sext i8 %103 to i32
%105 = load i8, i8* %16
%106 = sext i8 %105 to i32
%107 = load i64, i64* %13
%108 = add nsw i64 %107, 1
%109 = load i8, i8* %14
%110 = sext i8 %109 to i32
%111 = call i32 (i8*, i8*, ...) @sprintf(i8* %96, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %98, i32 %100, i64 %102, i32 %104, i32 %106, i64 %108, i32 %110)
%112 = load %struct.dyn_string_str*, %struct.dyn_string_str** %18
%113 = getelementptr inbounds [4096 x i8], [4096 x i8]* %21, i64 0, i64 0
%114 = call i32 @dyn_strcat(%struct.dyn_string_str* %112, i8* %113)
br label %115
115: ; preds = %95, %87
br label %116
116: ; preds = %115, %84
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 %44 [
i32 1, label %13
i32 2, label %33
]
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 %25
23: ; preds = %13
%24 = 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 %18, i32 %16)
br label %25
25: ; preds = %23, %21
%26 = call i32 @dyn_strcat(%struct.dyn_string_str* %7, i8* %12)
%27 = icmp eq i8* %6, null
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = 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)
%30 = call i32 @dyn_strcat(%struct.dyn_string_str* %7, i8* %12)
br label %31
31: ; preds = %28, %25
%32 = 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 %44
33: ; preds = %10
%34 = icmp eq i32 %8, 1
%35 = select i1 %34, i32 88, i32 86
%36 = select i1 %34, i32 86, i32 88
%37 = add nsw i64 %0, 1
%38 = sext i8 %1 to i32
%39 = sext i8 %5 to i32
%40 = add nsw i64 %2, 1
%41 = sext i8 %3 to i32
%42 = 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 %35, i32 %36, i64 %37, i32 %38, i32 %39, i64 %40, i32 %41)
%43 = call i32 @dyn_strcat(%struct.dyn_string_str* %7, i8* %12)
br label %44
44: ; preds = %10, %33, %31
ret void
}