void update_code(struct dyn_string_str *align_code_dyn, int op, int op_cnt,
                 int fnum, int show_code) {
  char align_char[4] = {"=-+"};
  char cigar_char[4] = {"MDI"};
  char tmp_cnt[20];
  if (op_cnt == 0)
    return;
  if (show_code == 8) {
    sprintf(tmp_cnt, "%d%c", op_cnt, cigar_char[op]);
  } else {
    if (op == 0)
      sprintf(tmp_cnt, "%c%d[%d]", align_char[op], op_cnt, fnum);
    else
      sprintf(tmp_cnt, "%c%d", align_char[op], op_cnt);
  }
  dyn_strcat(align_code_dyn, tmp_cnt);
}


x86 assembly (clang, -O0):
<update_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    0xec1(%rip),%eax
mov    %eax,-0x1c(%rbp)
mov    0xebc(%rip),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    115a <update_code+0x3a>
jmp    11ea <update_code+0xca>
cmpl   $0x8,-0x18(%rbp)
jne    1187 <update_code+0x67>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%edx
movslq -0xc(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%ecx
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11db <update_code+0xbb>
cmpl   $0x0,-0xc(%rbp)
jne    11b8 <update_code+0x98>
lea    -0x40(%rbp),%rdi
movslq -0xc(%rbp),%rax
movsbl -0x1c(%rbp,%rax,1),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11d6 <update_code+0xb6>
lea    -0x40(%rbp),%rdi
movslq -0xc(%rbp),%rax
movsbl -0x1c(%rbp,%rax,1),%edx
mov    -0x10(%rbp),%ecx
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11db <update_code+0xbb>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x0,%al
call   1030 <dyn_strcat@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_code>:
test   %edx,%edx
je     11ae <update_code+0x8e>
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %rdi,%r14
cmp    $0x8,%r8d
jne    1156 <update_code+0x36>
movslq %esi,%rax
lea    0xec0(%rip),%rcx
movsbl (%rax,%rcx,1),%ecx
lea    0xeb9(%rip),%rsi
mov    %rsp,%rdi
mov    %ebx,%edx
jmp    1174 <update_code+0x54>
test   %esi,%esi
je     117d <update_code+0x5d>
movslq %esi,%rax
lea    0xe9c(%rip),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xea7(%rip),%rsi
mov    %rsp,%rdi
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    119a <update_code+0x7a>
mov    %ecx,%eax
lea    0xe87(%rip),%rsi
mov    %rsp,%rdi
mov    $0x3d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <dyn_strcat@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.dyn_string_str = type opaque
@__const.update_code.align_char = [4 x i8] c"=-+\00"
@__const.update_code.cigar_char = [4 x i8] c"MDI\00"
@.str = [5 x i8] c"%d%c\00"
@.str.1 = [9 x i8] c"%c%d[%d]\00"
@.str.2 = [5 x i8] c"%c%d\00"
define void @update_code(%struct.dyn_string_str* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %struct.dyn_string_str*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [4 x i8]
%12 = alloca [4 x i8]
%13 = alloca [20 x i8]
store %struct.dyn_string_str* %0, %struct.dyn_string_str** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = bitcast [4 x i8]* %11 to i8*
%15 = bitcast [4 x i8]* %12 to i8*
%16 = load i32, i32* %8
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %5
br label %58
19: ; preds = %5
%20 = load i32, i32* %10
%21 = icmp eq i32 %20, 8
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%24 = load i32, i32* %8
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %12, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = call i32 (i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %29)
br label %54
31: ; preds = %19
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %44
34: ; preds = %31
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = load i32, i32* %8
%42 = load i32, i32* %9
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41, i32 %42)
br label %53
44: ; preds = %31
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = load i32, i32* %8
%52 = call i32 (i8*, i8*, ...) @sprintf(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %50, i32 %51)
br label %53
53: ; preds = %44, %34
br label %54
54: ; preds = %53, %22
%55 = load %struct.dyn_string_str*, %struct.dyn_string_str** %6
%56 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%57 = call i32 (%struct.dyn_string_str*, i8*, ...) bitcast (i32 (...)* @dyn_strcat to i32 (%struct.dyn_string_str*, i8*, ...)*)(%struct.dyn_string_str* %55, i8* %56)
br label %58
58: ; preds = %54, %18
ret void
}

LLVM IR (-O2):
%struct.dyn_string_str = type opaque
@__const.update_code.align_char = [4 x i8] c"=-+\00"
@__const.update_code.cigar_char = [4 x i8] c"MDI\00"
@.str = [5 x i8] c"%d%c\00"
@.str.1 = [9 x i8] c"%c%d[%d]\00"
@.str.2 = [5 x i8] c"%c%d\00"
define void @update_code(%struct.dyn_string_str* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [20 x i8]
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%8 = icmp eq i32 %2, 0
br i1 %8, label %29, label %9
9: ; preds = %5
%10 = icmp eq i32 %4, 8
br i1 %10, label %11, label %17
11: ; preds = %9
%12 = sext i32 %1 to i64
%13 = getelementptr inbounds [4 x i8], [4 x i8]* @__const.update_code.cigar_char, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %15)
br label %27
17: ; preds = %9
%18 = icmp eq i32 %1, 0
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 61, i32 %2, i32 %3)
br label %27
21: ; preds = %17
%22 = sext i32 %1 to i64
%23 = getelementptr inbounds [4 x i8], [4 x i8]* @__const.update_code.align_char, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %2)
br label %27
27: ; preds = %19, %21, %11
%28 = call i32 (%struct.dyn_string_str*, i8*, ...) bitcast (i32 (...)* @dyn_strcat to i32 (%struct.dyn_string_str*, i8*, ...)*)(%struct.dyn_string_str* %0, i8* %7)
br label %29
29: ; preds = %5, %27
ret void
}