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

/* Variables and functions */
int /*<<< orphan*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fread(char *, int, int, void *);
int /*<<< orphan*/ mkdir(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ sprintf(char *, char *, char);
void readLine(void *p) {
  int i = 0;
  char c = '0';
  char s[16];
  while (1) {
    fread(&c, 1, 1, p);
    if (c == '\n')
      break;
    sprintf(&s[i++], "%c", c);
  }
  puts(s);
  printf("%s", s);
  if (0 == access(s, F_OK))
    remove(s);
  mkdir(s);
}


x86 assembly (clang, -O0):
<readLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movb   $0x30,-0xd(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0xd(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <fread@plt>
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
jne    11ad <readLine+0x3d>
jmp    11d6 <readLine+0x66>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cltq
lea    -0x20(%rbp),%rdi
add    %rax,%rdi
lea    0xe38(%rip),%rsi
movsbl -0xd(%rbp),%edx
call   1090 <sprintf@plt>
jmp    1187 <readLine+0x17>
lea    -0x20(%rbp),%rdi
call   1050 <puts@plt>
lea    -0x20(%rbp),%rsi
lea    0xe19(%rip),%rdi
call   1070 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    0x2dde(%rip),%rax
mov    (%rax),%esi
call   1080 <access@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1218 <readLine+0xa8>
lea    -0x20(%rbp),%rdi
call   1030 <remove@plt>
lea    -0x20(%rbp),%rdi
call   1040 <mkdir@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readLine>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r15
movb   $0x30,0xf(%rsp)
lea    0xf(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1060 <fread@plt>
mov    0xf(%rsp),%al
cmp    $0xa,%al
je     11c8 <readLine+0x68>
lea    0x11(%rsp),%rbx
lea    0xf(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    %al,-0x1(%rbx)
movb   $0x0,(%rbx)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1060 <fread@plt>
movzbl 0xf(%rsp),%eax
add    $0x1,%rbx
cmp    $0xa,%al
jne    11a0 <readLine+0x40>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xe24(%rip),%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <access@plt>
test   %rax,%rax
jne    1204 <readLine+0xa4>
lea    0x10(%rsp),%rdi
call   1030 <remove@plt>
lea    0x10(%rsp),%rdi
call   1040 <mkdir@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [3 x i8] c"%s\00"
@F_OK = global i32 0
define void @readLine(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
%5 = alloca [16 x i8]
store i8* %0, i8** %2
store i32 0, i32* %3
store i8 48, i8* %4
br label %6
6: ; preds = %1, %13
%7 = load i8*, i8** %2
%8 = call i32 @fread(i8* %4, i32 1, i32 1, i8* %7)
%9 = load i8, i8* %4
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %13
12: ; preds = %6
br label %20
13: ; preds = %6
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %16
%18 = load i8, i8* %4
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %18)
br label %6
20: ; preds = %12
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%22 = call i32 @puts(i8* %21)
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%26 = load i32, i32* @F_OK
%27 = call i64 @access(i8* %25, i32 %26)
%28 = icmp eq i64 0, %27
br i1 %28, label %29, label %32
29: ; preds = %20
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%31 = call i32 @remove(i8* %30)
br label %32
32: ; preds = %29, %20
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%34 = call i32 @mkdir(i8* %33)
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@F_OK = global i32 0
define void @readLine(i8* nocapture %0) {
%2 = alloca i8
%3 = alloca [16 x i8]
store i8 48, i8* %2
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = call i32 @fread(i8* %2, i32 1, i32 1, i8* %0)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 10
br i1 %7, label %17, label %8
8: ; preds = %1, %8
%9 = phi i64 [ %11, %8 ], [ 0, %1 ]
%10 = phi i8 [ %15, %8 ], [ %6, %1 ]
%11 = add nuw i64 %9, 1
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %9
store i8 %10, i8* %12
%13 = getelementptr i8, i8* %12, i64 1
store i8 0, i8* %13
%14 = call i32 @fread(i8* %2, i32 1, i32 1, i8* %0)
%15 = load i8, i8* %2
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %8
17: ; preds = %8, %1
%18 = call i32 @puts(i8* %4)
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%20 = load i32, i32* @F_OK
%21 = call i64 @access(i8* %4, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 @remove(i8* %4)
br label %25
25: ; preds = %23, %17
%26 = call i32 @mkdir(i8* %4)
ret void
}