#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 O_NONBLOCK;
int O_RDWR;
scalar_t__ errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char *fgets(char *, int, int /*<<< orphan*/);
int open(char const *, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int sprintf(char *, char *, int, char, char);
int sscanf(char *, char *, int *, int *, char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
char *typename(char);
scalar_t__ write(int, char *, int);
void server(const char *dial) {
  int f = open(dial, O_RDWR | O_NONBLOCK);
  if (f < 0)
    printf("can't open %s\n", dial);
  else {
    char buffer[2048], name[2048], type, ans, *pstr;
    int n, pid, seq, w;
    printf("keyzen authorization server started\n");
    for (;;) {
      printf("waiting...");
      fflush(stdout);
      n = read(f, buffer, sizeof buffer - 1);
      printf("\n");
      if (n <= 0) {
        printf("error while reading dial %d %m\n", n);
        break;
      }
      buffer[n] = 0;
      n = sscanf(buffer, "%d %d %c%s", &seq, &pid, &type, name);
      if (n != 4) {
        printf("error while scanning dial %d field(s) read\n", n);
        break;
      }
      printf("For pid=%d, key %s of type %c: %s\n", pid, name, type,
             typename(type));
      do {
        printf(" .. do you grant (y/n)? ");
        errno = 0;
        pstr = fgets(buffer, sizeof buffer, stdin);
      } while (pstr && buffer[0] != 'y' && buffer[0] != 'n');
      if (!pstr) {
        if (errno)
          printf("error while reading stdin %m\n");
        else
          printf("disconnecting\n");
        break;
      }
      ans = buffer[0];
      if (ans != 'y' && ans != 'n') {
        printf("internal error ans=%c\n", ans);
        break;
      }
      if (type != '*')
        type = ans == 'y' ? '=' : '-';
      n = sprintf(buffer, "%d %c%c\n", seq, ans, type);
      w = (int)write(f, buffer, n);
      if (n != w) {
        printf("error while writing dial %d/%d %m\n", n, w);
        break;
      }
    }
    printf("keyzen authorization server stopped\n");
  }
}


x86 assembly (clang, -O0):
<server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
mov    0x2e2d(%rip),%rax
or     (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11de <server+0x4e>
mov    -0x8(%rbp),%rsi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14ea <server+0x35a>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    -0xc(%rbp),%edi
lea    -0x810(%rbp),%rsi
mov    $0x7ff,%edx
call   1050 <read@plt>
mov    %eax,-0x1024(%rbp)
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x1024(%rbp)
jg     1256 <server+0xc6>
mov    -0x1024(%rbp),%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14dc <server+0x34c>
movslq -0x1024(%rbp),%rax
movb   $0x0,-0x810(%rbp,%rax,1)
lea    -0x810(%rbp),%rdi
lea    -0x1010(%rbp),%r9
lea    0xde5(%rip),%rsi
lea    -0x102c(%rbp),%rdx
lea    -0x1028(%rbp),%rcx
lea    -0x1011(%rbp),%r8
call   1080 <sscanf@plt>
mov    %eax,-0x1024(%rbp)
cmpl   $0x4,-0x1024(%rbp)
je     12c0 <server+0x130>
mov    -0x1024(%rbp),%esi
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14dc <server+0x34c>
mov    -0x1028(%rbp),%eax
mov    %eax,-0x1044(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1040(%rbp)
movsbl -0x1011(%rbp),%eax
mov    %eax,-0x1034(%rbp)
movsbl -0x1011(%rbp),%edi
call   10b0 <typename@plt>
mov    -0x1044(%rbp),%esi
mov    -0x1040(%rbp),%rdx
mov    -0x1034(%rbp),%ecx
mov    %rax,%r8
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2c9c(%rip),%rax
movq   $0x0,(%rax)
lea    -0x810(%rbp),%rdi
mov    0x2c97(%rip),%rax
mov    (%rax),%edx
mov    $0x800,%esi
call   1060 <fgets@plt>
mov    %rax,-0x1020(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x1020(%rbp)
mov    %al,-0x1045(%rbp)
je     1395 <server+0x205>
movsbl -0x810(%rbp),%ecx
xor    %eax,%eax
cmp    $0x79,%ecx
mov    %al,-0x1045(%rbp)
je     1395 <server+0x205>
movsbl -0x810(%rbp),%eax
cmp    $0x6e,%eax
setne  %al
mov    %al,-0x1045(%rbp)
mov    -0x1045(%rbp),%al
test   $0x1,%al
jne    1317 <server+0x187>
cmpq   $0x0,-0x1020(%rbp)
jne    13e8 <server+0x258>
mov    0x2c10(%rip),%rax
cmpq   $0x0,(%rax)
je     13d5 <server+0x245>
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13e3 <server+0x253>
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14dc <server+0x34c>
mov    -0x810(%rbp),%al
mov    %al,-0x1012(%rbp)
movsbl -0x1012(%rbp),%eax
cmp    $0x79,%eax
je     142e <server+0x29e>
movsbl -0x1012(%rbp),%eax
cmp    $0x6e,%eax
je     142e <server+0x29e>
movsbl -0x1012(%rbp),%esi
lea    0xcdd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14dc <server+0x34c>
movsbl -0x1011(%rbp),%eax
cmp    $0x2a,%eax
je     145b <server+0x2cb>
movsbl -0x1012(%rbp),%edx
mov    $0x2d,%eax
mov    $0x3d,%ecx
cmp    $0x79,%edx
cmove  %ecx,%eax
mov    %al,-0x1011(%rbp)
lea    -0x810(%rbp),%rdi
mov    -0x102c(%rbp),%edx
mov    -0x1012(%rbp),%al
lea    0xca1(%rip),%rsi
movsbl %al,%ecx
movsbl -0x1011(%rbp),%r8d
ff
call   10a0 <sprintf@plt>
mov    %eax,-0x1024(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x810(%rbp),%rsi
mov    -0x1024(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x1030(%rbp)
mov    -0x1024(%rbp),%eax
cmp    -0x1030(%rbp),%eax
je     14d7 <server+0x347>
mov    -0x1024(%rbp),%esi
mov    -0x1030(%rbp),%edx
lea    0xc54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14dc <server+0x34c>
jmp    11ec <server+0x5c>
lea    0xc5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<server>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rdi,%rbx
mov    0x2e1d(%rip),%rax
mov    0x2e0e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
call   10b0 <open@plt>
test   %eax,%eax
js     1370 <server+0x1c0>
mov    %eax,%ebp
lea    0xf22(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rbx
lea    0xe97(%rip),%r12
mov    0x2dc4(%rip),%r15
mov    0x2dcd(%rip),%r14
mov    %ebp,0x4(%rsp)
jmp    124f <server+0x9f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%edx
movzbl %al,%r8d
mov    %rbx,%rdi
lea    0xeb0(%rip),%rsi
call   10c0 <sprintf@plt>
mov    %eax,%r13d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    %eax,%r13d
jne    13be <server+0x20e>
lea    0xdb9(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x7ff,%edx
call   1070 <read@plt>
mov    %eax,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jle    1392 <server+0x1e2>
mov    %ebp,%eax
movb   $0x0,0x10(%rsp,%rax,1)
mov    %rbx,%rdi
lea    0xd9b(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x3(%rsp),%r8
lea    0x810(%rsp),%r9
call   10a0 <sscanf@plt>
cmp    $0x4,%eax
jne    139d <server+0x1ed>
mov    0xc(%rsp),%r13d
movsbl 0x3(%rsp),%ebp
mov    %ebp,%edi
call   10d0 <typename@plt>
lea    0xd95(%rip),%rdi
mov    %r13d,%esi
lea    0x810(%rsp),%rdx
mov    %ebp,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1060 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movq   $0x0,(%r15)
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x800,%esi
call   1080 <fgets@plt>
movzbl 0x10(%rsp),%edx
test   %rax,%rax
je     1335 <server+0x185>
cmp    $0x79,%dl
je     1335 <server+0x185>
cmp    $0x6e,%dl
jne    1300 <server+0x150>
test   %rax,%rax
mov    0x4(%rsp),%ebp
je     13a8 <server+0x1f8>
movsbl %dl,%ecx
cmp    $0x6e,%dl
je     134f <server+0x19f>
cmp    $0x79,%dl
jne    13d3 <server+0x223>
mov    $0x2a,%al
cmpb   $0x2a,0x3(%rsp)
je     1220 <server+0x70>
cmp    $0x79,%dl
sete   %al
shl    $0x4,%al
or     $0x2d,%al
mov    %al,0x3(%rsp)
jmp    1220 <server+0x70>
lea    0xc89(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <printf@plt>
lea    0xc81(%rip),%rdi
mov    %ebp,%esi
jmp    13dc <server+0x22c>
lea    0xca1(%rip),%rdi
mov    %eax,%esi
jmp    13dc <server+0x22c>
cmpq   $0x0,(%r15)
je     1401 <server+0x251>
lea    0xcf8(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13e3 <server+0x233>
lea    0xd26(%rip),%rdi
mov    %r13d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13e3 <server+0x233>
lea    0xcf1(%rip),%rdi
mov    %ecx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd56(%rip),%rdi
call   1040 <puts@plt>
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd2a(%rip),%rdi
call   1040 <puts@plt>
jmp    13e3 <server+0x233>

LLVM IR (-O0):
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str = [15 x i8] c"can't open %s\0A\00"
@.str.1 = [37 x i8] c"keyzen authorization server started\0A\00"
@.str.2 = [11 x i8] c"waiting...\00"
@stdout = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [32 x i8] c"error while reading dial %d %m\0A\00"
@.str.5 = [11 x i8] c"%d %d %c%s\00"
@.str.6 = [44 x i8] c"error while scanning dial %d field(s) read\0A\00"
@.str.7 = [35 x i8] c"For pid=%d, key %s of type %c: %s\0A\00"
@.str.8 = [25 x i8] c" .. do you grant (y/n)? \00"
@errno = global i64 0
@stdin = global i32 0
@.str.9 = [30 x i8] c"error while reading stdin %m\0A\00"
@.str.10 = [15 x i8] c"disconnecting\0A\00"
@.str.11 = [23 x i8] c"internal error ans=%c\0A\00"
@.str.12 = [9 x i8] c"%d %c%c\0A\00"
@.str.13 = [35 x i8] c"error while writing dial %d/%d %m\0A\00"
@.str.14 = [37 x i8] c"keyzen authorization server stopped\0A\00"
define void @server(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [2048 x i8]
%5 = alloca [2048 x i8]
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %2
%13 = load i8*, i8** %2
%14 = load i32, i32* @O_RDWR
%15 = load i32, i32* @O_NONBLOCK
%16 = or i32 %14, %15
%17 = call i32 @open(i8* %13, i32 %16)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %1
%21 = load i8*, i8** %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %135
23: ; preds = %1
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %132, %23
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* @stdout
%28 = call i32 @fflush(i32 %27)
%29 = load i32, i32* %3
%30 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%31 = call i32 @read(i32 %29, i8* %30, i32 2047)
store i32 %31, i32* %9
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* %9
%34 = icmp sle i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %25
%36 = load i32, i32* %9
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %36)
br label %133
38: ; preds = %25
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 %40
store i8 0, i8* %41
%42 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%43 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%44 = call i32 @sscanf(i8* %42, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32* %11, i32* %10, i8* %6, i8* %43)
store i32 %44, i32* %9
%45 = load i32, i32* %9
%46 = icmp ne i32 %45, 4
br i1 %46, label %47, label %50
47: ; preds = %38
%48 = load i32, i32* %9
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %48)
br label %133
50: ; preds = %38
%51 = load i32, i32* %10
%52 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%53 = load i8, i8* %6
%54 = sext i8 %53 to i32
%55 = load i8, i8* %6
%56 = call i8* @typename(i8 signext %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i32 %51, i8* %52, i32 %54, i8* %56)
br label %58
58: ; preds = %76, %50
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
store i64 0, i64* @errno
%60 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%61 = load i32, i32* @stdin
%62 = call i8* @fgets(i8* %60, i32 2048, i32 %61)
store i8* %62, i8** %8
br label %63
63: ; preds = %58
%64 = load i8*, i8** %8
%65 = icmp ne i8* %64, null
br i1 %65, label %66, label %76
66: ; preds = %63
%67 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 121
br i1 %70, label %71, label %76
71: ; preds = %66
%72 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %74, 110
br label %76
76: ; preds = %71, %66, %63
%77 = phi i1 [ false, %66 ], [ false, %63 ], [ %75, %71 ]
br i1 %77, label %58, label %78
78: ; preds = %76
%79 = load i8*, i8** %8
%80 = icmp ne i8* %79, null
br i1 %80, label %89, label %81
81: ; preds = %78
%82 = load i64, i64* @errno
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %81
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
br label %88
86: ; preds = %81
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
br label %88
88: ; preds = %86, %84
br label %133
89: ; preds = %78
%90 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%91 = load i8, i8* %90
store i8 %91, i8* %7
%92 = load i8, i8* %7
%93 = sext i8 %92 to i32
%94 = icmp ne i32 %93, 121
br i1 %94, label %95, label %103
95: ; preds = %89
%96 = load i8, i8* %7
%97 = sext i8 %96 to i32
%98 = icmp ne i32 %97, 110
br i1 %98, label %99, label %103
99: ; preds = %95
%100 = load i8, i8* %7
%101 = sext i8 %100 to i32
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i32 %101)
br label %133
103: ; preds = %95, %89
%104 = load i8, i8* %6
%105 = sext i8 %104 to i32
%106 = icmp ne i32 %105, 42
br i1 %106, label %107, label %114
107: ; preds = %103
%108 = load i8, i8* %7
%109 = sext i8 %108 to i32
%110 = icmp eq i32 %109, 121
%111 = zext i1 %110 to i64
%112 = select i1 %110, i32 61, i32 45
%113 = trunc i32 %112 to i8
store i8 %113, i8* %6
br label %114
114: ; preds = %107, %103
%115 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%116 = load i32, i32* %11
%117 = load i8, i8* %7
%118 = load i8, i8* %6
%119 = call i32 @sprintf(i8* %115, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %116, i8 signext %117, i8 signext %118)
store i32 %119, i32* %9
%120 = load i32, i32* %3
%121 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%122 = load i32, i32* %9
%123 = call i64 @write(i32 %120, i8* %121, i32 %122)
%124 = trunc i64 %123 to i32
store i32 %124, i32* %12
%125 = load i32, i32* %9
%126 = load i32, i32* %12
%127 = icmp ne i32 %125, %126
br i1 %127, label %128, label %132
128: ; preds = %114
%129 = load i32, i32* %9
%130 = load i32, i32* %12
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0), i32 %129, i32 %130)
br label %133
132: ; preds = %114
br label %25
133: ; preds = %128, %99, %88, %47, %35
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0))
br label %135
135: ; preds = %133, %20
ret void
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str = [15 x i8] c"can't open %s\0A\00"
@.str.2 = [11 x i8] c"waiting...\00"
@stdout = global i32 0
@.str.4 = [32 x i8] c"error while reading dial %d %m\0A\00"
@.str.5 = [11 x i8] c"%d %d %c%s\00"
@.str.6 = [44 x i8] c"error while scanning dial %d field(s) read\0A\00"
@.str.7 = [35 x i8] c"For pid=%d, key %s of type %c: %s\0A\00"
@.str.8 = [25 x i8] c" .. do you grant (y/n)? \00"
@errno = global i64 0
@stdin = global i32 0
@.str.9 = [30 x i8] c"error while reading stdin %m\0A\00"
@.str.11 = [23 x i8] c"internal error ans=%c\0A\00"
@.str.12 = [9 x i8] c"%d %c%c\0A\00"
@.str.13 = [35 x i8] c"error while writing dial %d/%d %m\0A\00"
@str = [36 x i8] c"keyzen authorization server started\00"
@str.15 = [14 x i8] c"disconnecting\00"
@str.16 = [36 x i8] c"keyzen authorization server stopped\00"
define void @server(i8* %0) {
%2 = alloca [2048 x i8]
%3 = alloca [2048 x i8]
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = load i32, i32* @O_RDWR
%8 = load i32, i32* @O_NONBLOCK
%9 = or i32 %8, %7
%10 = tail call i32 @open(i8* %0, i32 %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %82
14: ; preds = %1
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%17 = bitcast i32* %5 to i8*
%18 = bitcast i32* %6 to i8*
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %70, %14
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* @stdout
%23 = call i32 @fflush(i32 %22)
%24 = call i32 @read(i32 %10, i8* %15, i32 2047)
%25 = call i32 @putchar(i32 10)
%26 = icmp slt i32 %24, 1
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %24)
br label %80
29: ; preds = %20
%30 = zext i32 %24 to i64
%31 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 %30
store i8 0, i8* %31
%32 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32* %6, i32* %5, i8* %4, i8* %16)
%33 = icmp eq i32 %32, 4
br i1 %33, label %36, label %34
34: ; preds = %29
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %32)
br label %80
36: ; preds = %29
%37 = load i32, i32* %5
%38 = load i8, i8* %4
%39 = sext i8 %38 to i32
%40 = call i8* @typename(i8 signext %38)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i32 %37, i8* %16, i32 %39, i8* %40)
br label %42
42: ; preds = %42, %36
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
store i64 0, i64* @errno
%44 = load i32, i32* @stdin
%45 = call i8* @fgets(i8* %15, i32 2048, i32 %44)
%46 = icmp ne i8* %45, null
%47 = load i8, i8* %15
%48 = icmp ne i8 %47, 121
%49 = select i1 %46, i1 %48, i1 false
%50 = icmp ne i8 %47, 110
%51 = select i1 %49, i1 %50, i1 false
br i1 %51, label %42, label %52
52: ; preds = %42
br i1 %46, label %60, label %53
53: ; preds = %52
%54 = load i64, i64* @errno
%55 = icmp eq i64 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %53
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
br label %80
58: ; preds = %53
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.15, i64 0, i64 0))
br label %80
60: ; preds = %52
switch i8 %47, label %61 [
i8 121, label %64
i8 110, label %64
]
61: ; preds = %60
%62 = sext i8 %47 to i32
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i32 %62)
br label %80
64: ; preds = %60, %60
%65 = load i8, i8* %4
%66 = icmp eq i8 %65, 42
br i1 %66, label %70, label %67
67: ; preds = %64
%68 = icmp eq i8 %47, 121
%69 = select i1 %68, i8 61, i8 45
store i8 %69, i8* %4
br label %70
70: ; preds = %67, %64
%71 = phi i8 [ %69, %67 ], [ 42, %64 ]
%72 = load i32, i32* %6
%73 = call i32 @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %72, i8 signext %47, i8 signext %71)
%74 = call i64 @write(i32 %10, i8* %15, i32 %73)
%75 = trunc i64 %74 to i32
%76 = icmp eq i32 %73, %75
br i1 %76, label %20, label %77
77: ; preds = %70
%78 = trunc i64 %74 to i32
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0), i32 %73, i32 %78)
br label %80
80: ; preds = %56, %58, %77, %61, %34, %27
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.16, i64 0, i64 0))
br label %82
82: ; preds = %80, %12
ret void
}