#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*/ FILE;

/* Variables and functions */
scalar_t__ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ log_fatal(char *, char *);
int saveMainTagEnd(FILE *config_fd, char *tag, int tabbing) {
  int i = 0;
  for (i = 0; i < tabbing; i++) {
    if (fprintf(config_fd, "\t") == 0) {
      break;
    }
  }
  if (fprintf(config_fd, "</%s>\n", tag) < 0) {
    log_fatal("Error saving tag: %s", tag);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<saveMainTagEnd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1181 <saveMainTagEnd+0x61>
mov    -0x10(%rbp),%rdi
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmp    $0x0,%rax
jne    116e <saveMainTagEnd+0x4e>
jmp    1181 <saveMainTagEnd+0x61>
jmp    1173 <saveMainTagEnd+0x53>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1141 <saveMainTagEnd+0x21>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmp    $0x0,%rax
jge    11bd <saveMainTagEnd+0x9d>
mov    -0x18(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1040 <log_fatal@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c4 <saveMainTagEnd+0xa4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saveMainTagEnd>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
test   %edx,%edx
jle    115b <saveMainTagEnd+0x3b>
mov    %edx,%ebp
mov    $0x1,%ebx
lea    0xec0(%rip),%r15
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %rax,%rax
je     115b <saveMainTagEnd+0x3b>
lea    0x1(%rbx),%eax
cmp    %ebp,%ebx
mov    %eax,%ebx
jl     1140 <saveMainTagEnd+0x20>
lea    0xea0(%rip),%rsi
xor    %ebp,%ebp
mov    %r12,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %rax,%rax
jns    118a <saveMainTagEnd+0x6a>
lea    0xe8c(%rip),%rdi
mov    %r14,%rsi
call   1040 <log_fatal@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\09\00"
@.str.1 = [7 x i8] c"</%s>\0A\00"
@.str.2 = [21 x i8] c"Error saving tag: %s\00"
define i32 @saveMainTagEnd(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 0, i32* %8
store i32 0, i32* %8
br label %9
9: ; preds = %19, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = load i32*, i32** %5
%15 = call i64 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %22
18: ; preds = %13
br label %19
19: ; preds = %18
%20 = load i32, i32* %8
%21 = add nsw i32 %20, 1
store i32 %21, i32* %8
br label %9
22: ; preds = %17, %9
%23 = load i32*, i32** %5
%24 = load i8*, i8** %6
%25 = call i64 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i8*, i8** %6
%29 = call i32 @log_fatal(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %28)
store i32 1, i32* %4
br label %31
30: ; preds = %22
store i32 0, i32* %4
br label %31
31: ; preds = %30, %27
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@.str = [2 x i8] c"\09\00"
@.str.1 = [7 x i8] c"</%s>\0A\00"
@.str.2 = [21 x i8] c"Error saving tag: %s\00"
define i32 @saveMainTagEnd(i32* nocapture %0, i8* %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %12
5: ; preds = %3, %5
%6 = phi i32 [ %9, %5 ], [ 0, %3 ]
%7 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
%9 = add nuw nsw i32 %6, 1
%10 = icmp slt i32 %9, %2
%11 = select i1 %8, i1 %10, i1 false
br i1 %11, label %5, label %12
12: ; preds = %5, %3
%13 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @log_fatal(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %17
17: ; preds = %12, %15
%18 = phi i32 [ 1, %15 ], [ 0, %12 ]
ret i32 %18
}