#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ print_escaped(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
void _nl_log_untranslated(const char *logfilename, const char *domainname,
                          const char *msgid1, const char *msgid2, int plural) {
  static char *last_logfilename = NULL;
  static FILE *last_logfile = NULL;
  FILE *logfile;
  if (last_logfilename == NULL || strcmp(logfilename, last_logfilename) != 0) {
    if (last_logfilename != NULL) {
      if (last_logfile != NULL) {
        fclose(last_logfile);
        last_logfile = NULL;
      }
      free(last_logfilename);
      last_logfilename = NULL;
    }
    last_logfilename = (char *)malloc(strlen(logfilename) + 1);
    if (last_logfilename == NULL)
      return;
    strcpy(last_logfilename, logfilename);
    last_logfile = fopen(logfilename, "a");
    if (last_logfile == NULL)
      return;
  }
  logfile = last_logfile;
  fprintf(logfile, "domain ");
  print_escaped(logfile, domainname);
  fprintf(logfile, "\nmsgid ");
  print_escaped(logfile, msgid1);
  if (plural) {
    fprintf(logfile, "\nmsgid_plural ");
    print_escaped(logfile, msgid2);
    fprintf(logfile, "\nmsgstr[0] \"\"\n");
  } else
    fprintf(logfile, "\nmsgstr \"\"\n");
  putc('\n', logfile);
}


x86 assembly (clang, -O0):
<_nl_log_untranslated>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
cmpq   $0x0,0x2eb4(%rip)
je     11e4 <_nl_log_untranslated+0x44>
mov    -0x8(%rbp),%rdi
mov    0x2ea3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     129c <_nl_log_untranslated+0xfc>
cmpq   $0x0,0x2e8c(%rip)
je     122e <_nl_log_untranslated+0x8e>
cmpq   $0x0,0x2e86(%rip)
je     1217 <_nl_log_untranslated+0x77>
mov    0x2e79(%rip),%rdi
call   1050 <fclose@plt>
movq   $0x0,0x2e69(%rip)
mov    0x2e5a(%rip),%rdi
call   1030 <free@plt>
movq   $0x0,0x2e4a(%rip)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   10a0 <malloc@plt>
mov    %rax,0x2e2e(%rip)
cmpq   $0x0,0x2e26(%rip)
jne    125d <_nl_log_untranslated+0xbd>
jmp    133b <_nl_log_untranslated+0x19b>
mov    0x2e14(%rip),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xd88(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,0x2dfc(%rip)
cmpq   $0x0,0x2df4(%rip)
jne    1297 <_nl_log_untranslated+0xf7>
jmp    133b <_nl_log_untranslated+0x19b>
jmp    129c <_nl_log_untranslated+0xfc>
mov    0x2ddd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xd50(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10c0 <print_escaped@plt>
mov    -0x30(%rbp),%rdi
lea    0xd3b(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10c0 <print_escaped@plt>
cmpl   $0x0,-0x24(%rbp)
je     131d <_nl_log_untranslated+0x17d>
mov    -0x30(%rbp),%rdi
lea    0xd1c(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10c0 <print_escaped@plt>
mov    -0x30(%rbp),%rdi
lea    0xd0e(%rip),%rsi
call   1090 <fprintf@plt>
jmp    132d <_nl_log_untranslated+0x18d>
mov    -0x30(%rbp),%rdi
lea    0xd08(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rsi
mov    $0xa,%edi
call   1080 <putc@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_nl_log_untranslated>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r15d
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    0x2eba(%rip),%rsi
test   %rsi,%rsi
je     1216 <_nl_log_untranslated+0x76>
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1265 <_nl_log_untranslated+0xc5>
mov    0x2e9d(%rip),%rdi
test   %rdi,%rdi
je     1216 <_nl_log_untranslated+0x76>
mov    0x2e99(%rip),%rax
test   %rax,%rax
je     1206 <_nl_log_untranslated+0x66>
mov    %rax,%rdi
call   1050 <fclose@plt>
movq   $0x0,0x2e81(%rip)
mov    0x2e72(%rip),%rdi
call   1030 <free@plt>
movq   $0x0,0x2e62(%rip)
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   1090 <malloc@plt>
mov    %rax,0x2e4a(%rip)
test   %rax,%rax
je     125c <_nl_log_untranslated+0xbc>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xdbb(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,0x2e29(%rip)
test   %rax,%rax
jne    126c <_nl_log_untranslated+0xcc>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e14(%rip),%rbx
lea    0xd8f(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10c0 <print_escaped@plt>
lea    0xd73(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10c0 <print_escaped@plt>
test   %r15d,%r15d
je     12eb <_nl_log_untranslated+0x14b>
lea    0xd52(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <print_escaped@plt>
lea    0xd3d(%rip),%rdi
mov    $0xe,%esi
jmp    12f7 <_nl_log_untranslated+0x157>
lea    0xd3e(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <putc@plt>

LLVM IR (-O0):
@_nl_log_untranslated.last_logfilename = internal global i8* null
@_nl_log_untranslated.last_logfile = internal global i32* null
@.str = [2 x i8] c"a\00"
@.str.1 = [8 x i8] c"domain \00"
@.str.2 = [8 x i8] c"\0Amsgid \00"
@.str.3 = [15 x i8] c"\0Amsgid_plural \00"
@.str.4 = [15 x i8] c"\0Amsgstr[0] \22\22\0A\00"
@.str.5 = [12 x i8] c"\0Amsgstr \22\22\0A\00"
define void @_nl_log_untranslated(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%12 = load i8*, i8** @_nl_log_untranslated.last_logfilename
%13 = icmp eq i8* %12, null
br i1 %13, label %19, label %14
14: ; preds = %5
%15 = load i8*, i8** %6
%16 = load i8*, i8** @_nl_log_untranslated.last_logfilename
%17 = call i64 @strcmp(i8* %15, i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %50
19: ; preds = %14, %5
%20 = load i8*, i8** @_nl_log_untranslated.last_logfilename
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i32*, i32** @_nl_log_untranslated.last_logfile
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32*, i32** @_nl_log_untranslated.last_logfile
%27 = call i32 @fclose(i32* %26)
store i32* null, i32** @_nl_log_untranslated.last_logfile
br label %28
28: ; preds = %25, %22
%29 = load i8*, i8** @_nl_log_untranslated.last_logfilename
%30 = call i32 @free(i8* %29)
store i8* null, i8** @_nl_log_untranslated.last_logfilename
br label %31
31: ; preds = %28, %19
%32 = load i8*, i8** %6
%33 = call i64 @strlen(i8* %32)
%34 = add nsw i64 %33, 1
%35 = call i64 @malloc(i64 %34)
%36 = inttoptr i64 %35 to i8*
store i8* %36, i8** @_nl_log_untranslated.last_logfilename
%37 = load i8*, i8** @_nl_log_untranslated.last_logfilename
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %40
39: ; preds = %31
br label %78
40: ; preds = %31
%41 = load i8*, i8** @_nl_log_untranslated.last_logfilename
%42 = load i8*, i8** %6
%43 = call i32 @strcpy(i8* %41, i8* %42)
%44 = load i8*, i8** %6
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %45, i32** @_nl_log_untranslated.last_logfile
%46 = load i32*, i32** @_nl_log_untranslated.last_logfile
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %49
48: ; preds = %40
br label %78
49: ; preds = %40
br label %50
50: ; preds = %49, %14
%51 = load i32*, i32** @_nl_log_untranslated.last_logfile
store i32* %51, i32** %11
%52 = load i32*, i32** %11
%53 = call i32 @fprintf(i32* %52, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%54 = load i32*, i32** %11
%55 = load i8*, i8** %7
%56 = call i32 @print_escaped(i32* %54, i8* %55)
%57 = load i32*, i32** %11
%58 = call i32 @fprintf(i32* %57, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%59 = load i32*, i32** %11
%60 = load i8*, i8** %8
%61 = call i32 @print_escaped(i32* %59, i8* %60)
%62 = load i32, i32* %10
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %72
64: ; preds = %50
%65 = load i32*, i32** %11
%66 = call i32 @fprintf(i32* %65, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%67 = load i32*, i32** %11
%68 = load i8*, i8** %9
%69 = call i32 @print_escaped(i32* %67, i8* %68)
%70 = load i32*, i32** %11
%71 = call i32 @fprintf(i32* %70, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %75
72: ; preds = %50
%73 = load i32*, i32** %11
%74 = call i32 @fprintf(i32* %73, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %75
75: ; preds = %72, %64
%76 = load i32*, i32** %11
%77 = call i32 @putc(i8 signext 10, i32* %76)
br label %78
78: ; preds = %75, %48, %39
ret void
}

LLVM IR (-O2):
@_nl_log_untranslated.last_logfilename = internal unnamed_addr global i8* null
@_nl_log_untranslated.last_logfile = internal unnamed_addr global i32* null
@.str = [2 x i8] c"a\00"
@.str.1 = [8 x i8] c"domain \00"
@.str.2 = [8 x i8] c"\0Amsgid \00"
@.str.3 = [15 x i8] c"\0Amsgid_plural \00"
@.str.4 = [15 x i8] c"\0Amsgstr[0] \22\22\0A\00"
@.str.5 = [12 x i8] c"\0Amsgstr \22\22\0A\00"
define void @_nl_log_untranslated(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = load i8*, i8** @_nl_log_untranslated.last_logfilename
%7 = icmp eq i8* %6, null
br i1 %7, label %25, label %8
8: ; preds = %5
%9 = tail call i64 @strcmp(i8* %0, i8* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = load i32*, i32** @_nl_log_untranslated.last_logfile
br label %35
13: ; preds = %8
%14 = load i8*, i8** @_nl_log_untranslated.last_logfilename
%15 = icmp eq i8* %14, null
br i1 %15, label %25, label %16
16: ; preds = %13
%17 = load i32*, i32** @_nl_log_untranslated.last_logfile
%18 = icmp eq i32* %17, null
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i32 @fclose(i32* %17)
store i32* null, i32** @_nl_log_untranslated.last_logfile
%21 = load i8*, i8** @_nl_log_untranslated.last_logfilename
br label %22
22: ; preds = %19, %16
%23 = phi i8* [ %21, %19 ], [ %14, %16 ]
%24 = tail call i32 @free(i8* %23)
store i8* null, i8** @_nl_log_untranslated.last_logfilename
br label %25
25: ; preds = %5, %22, %13
%26 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%27 = add nsw i64 %26, 1
%28 = tail call i64 @malloc(i64 %27)
%29 = inttoptr i64 %28 to i8*
store i8* %29, i8** @_nl_log_untranslated.last_logfilename
%30 = icmp eq i64 %28, 0
br i1 %30, label %50, label %31
31: ; preds = %25
%32 = tail call i32 @strcpy(i8* %29, i8* %0)
%33 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %33, i32** @_nl_log_untranslated.last_logfile
%34 = icmp eq i32* %33, null
br i1 %34, label %50, label %35
35: ; preds = %11, %31
%36 = phi i32* [ %12, %11 ], [ %33, %31 ]
%37 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 7, i64 1, i32* %36)
%38 = tail call i32 @print_escaped(i32* %36, i8* %1)
%39 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 7, i64 1, i32* %36)
%40 = tail call i32 @print_escaped(i32* %36, i8* %2)
%41 = icmp eq i32 %4, 0
br i1 %41, label %46, label %42
42: ; preds = %35
%43 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 14, i64 1, i32* %36)
%44 = tail call i32 @print_escaped(i32* %36, i8* %3)
%45 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i64 14, i64 1, i32* %36)
br label %48
46: ; preds = %35
%47 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64 11, i64 1, i32* %36)
br label %48
48: ; preds = %46, %42
%49 = tail call i32 @putc(i8 signext 10, i32* %36)
br label %50
50: ; preds = %31, %25, %48
ret void
}