#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *fgets(char *, int, int /*<<< orphan*/ *);
char *iconv_string_lossy(char *, int, char *, char *);
char *fl_dclst_read_line(FILE *fp) {
  char buf[1024];
  char *e = fgets(buf, sizeof(buf), fp);
  if (e == NULL)
    return NULL;
  char *line = iconv_string_lossy(buf, -1, "WINDOWS-1252", "UTF-8");
  return line;
}


x86 assembly (clang, -O0):
<fl_dclst_read_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
jne    1166 <fl_dclst_read_line+0x46>
movq   $0x0,-0x8(%rbp)
jmp    1197 <fl_dclst_read_line+0x77>
lea    -0x410(%rbp),%rdi
mov    $0xffffffff,%esi
lea    0xe87(%rip),%rdx
lea    0xe8d(%rip),%rcx
call   1030 <iconv_string_lossy@plt>
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fl_dclst_read_line>:
sub    $0x408,%rsp
mov    %rdi,%rdx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     115f <fl_dclst_read_line+0x3f>
lea    0xebd(%rip),%rdx
lea    0xec3(%rip),%rcx
mov    %rsp,%rdi
mov    $0xffffffff,%esi
call   1030 <iconv_string_lossy@plt>
add    $0x408,%rsp
ret
xor    %eax,%eax
add    $0x408,%rsp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"WINDOWS-1252\00"
@.str.1 = [6 x i8] c"UTF-8\00"
define i8* @fl_dclst_read_line(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [1024 x i8]
%5 = alloca i8*
%6 = alloca i8*
store i32* %0, i32** %3
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = load i32*, i32** %3
%9 = call i8* @fgets(i8* %7, i32 1024, i32* %8)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %1
store i8* null, i8** %2
br label %17
13: ; preds = %1
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%15 = call i8* @iconv_string_lossy(i8* %14, i32 -1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %15, i8** %6
%16 = load i8*, i8** %6
store i8* %16, i8** %2
br label %17
17: ; preds = %13, %12
%18 = load i8*, i8** %2
ret i8* %18
}

LLVM IR (-O2):
@.str = [13 x i8] c"WINDOWS-1252\00"
@.str.1 = [6 x i8] c"UTF-8\00"
define i8* @fl_dclst_read_line(i32* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i8* @fgets(i8* %3, i32 1024, i32* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = call i8* @iconv_string_lossy(i8* %3, i32 -1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %1, %6
%9 = phi i8* [ %7, %6 ], [ null, %1 ]
ret i8* %9
}