char pty(mfdp, sfdp)
int *mfdp, *sfdp;
{
  char *first, *second;
  static char master[] = "/dev/pty??", slave[] = "/dev/tty??";
  for (first = "pqrs"; *first != '\0'; ++first) {
    ((master) + (sizeof(master) / sizeof(*(master))))[-3] = *first;
    ((slave) + (sizeof(slave) / sizeof(*(slave))))[-3] = *first;
    for (second = "0123456789abcdef"; *second != '\0'; ++second) {
      ((master) + (sizeof(master) / sizeof(*(master))))[-2] = *second;
      *mfdp = open(master, 2);
      if (*mfdp >= 0) {
        ((slave) + (sizeof(slave) / sizeof(*(slave))))[-2] = *second;
        *sfdp = open(slave, 2);
        if (*sfdp >= 0)
          return ((0 == 0));
        close(*mfdp);
      }
    }
  }
  return ((!(0 == 0)));
}


x86 assembly (clang, -O0):
<pty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xec9(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1228 <pty+0x108>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2ee1(%rip)
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2ee0(%rip)
lea    0xe9b(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1212 <pty+0xf2>
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2eaf(%rip)
lea    0x2e9f(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1040 <open@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jl     11fc <pty+0xdc>
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2e86(%rip)
lea    0x2e76(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1040 <open@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jl     11ef <pty+0xcf>
movb   $0x1,-0x1(%rbp)
jmp    122c <pty+0x10c>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1030 <close@plt>
jmp    1201 <pty+0xe1>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    116e <pty+0x4e>
jmp    1217 <pty+0xf7>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113b <pty+0x1b>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pty>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movb   $0x70,0x2f00(%rip)
movb   $0x70,0x2f04(%rip)
mov    $0x30,%al
lea    0x2ee8(%rip),%r15
lea    0xeb1(%rip),%r13
lea    0x2ee5(%rip),%r12
xor    %ebp,%ebp
jmp    1179 <pty+0x59>
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%edi
xor    %eax,%eax
call   1030 <close@plt>
movzbl 0x1(%rbp,%r13,1),%eax
add    $0x1,%rbp
cmp    $0x10,%rbp
je     11bb <pty+0x9b>
mov    %al,0x2eba(%rip)
mov    %r15,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <open@plt>
mov    %eax,(%rbx)
test   %eax,%eax
js     1169 <pty+0x49>
movzbl 0x0(%rbp,%r13,1),%eax
mov    %al,0x2ea4(%rip)
mov    %r12,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <open@plt>
mov    %eax,(%r14)
test   %eax,%eax
js     1160 <pty+0x40>
jmp    12b6 <pty+0x196>
movb   $0x71,0x2e76(%rip)
movb   $0x71,0x2e7a(%rip)
mov    $0x30,%al
lea    0x2e5e(%rip),%r15
lea    0x2e62(%rip),%r12
xor    %ebp,%ebp
jmp    11f0 <pty+0xd0>
nopl   (%rax)
movzbl 0x1(%rbp,%r13,1),%eax
add    $0x1,%rbp
cmp    $0x10,%rbp
je     123c <pty+0x11c>
mov    %al,0x2e43(%rip)
mov    %r15,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <open@plt>
mov    %eax,(%rbx)
test   %eax,%eax
js     11e0 <pty+0xc0>
movzbl 0x0(%rbp,%r13,1),%eax
mov    %al,0x2e2d(%rip)
mov    %r12,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <open@plt>
mov    %eax,(%r14)
test   %eax,%eax
jns    12b6 <pty+0x196>
mov    (%rbx),%edi
xor    %eax,%eax
call   1030 <close@plt>
jmp    11e0 <pty+0xc0>
movb   $0x72,0x2df5(%rip)
movb   $0x72,0x2df9(%rip)
mov    $0x30,%al
lea    0x2ddd(%rip),%r15
lea    0x2de1(%rip),%r12
xor    %ebp,%ebp
jmp    1279 <pty+0x159>
xchg   %ax,%ax
mov    (%rbx),%edi
xor    %eax,%eax
call   1030 <close@plt>
movzbl 0x1(%rbp,%r13,1),%eax
add    $0x1,%rbp
cmp    $0x10,%rbp
je     12c7 <pty+0x1a7>
mov    %al,0x2dba(%rip)
mov    %r15,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <open@plt>
mov    %eax,(%rbx)
test   %eax,%eax
js     1269 <pty+0x149>
movzbl 0x0(%rbp,%r13,1),%eax
mov    %al,0x2da4(%rip)
mov    %r12,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <open@plt>
mov    %eax,(%r14)
test   %eax,%eax
js     1260 <pty+0x140>
mov    $0x1,%al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movb   $0x73,0x2d6a(%rip)
movb   $0x73,0x2d6e(%rip)
mov    $0x30,%al
lea    0x2d52(%rip),%r15
lea    0x2d56(%rip),%r12
xor    %ebp,%ebp
jmp    1300 <pty+0x1e0>
nopl   0x0(%rax)
movzbl 0x1(%rbp,%r13,1),%eax
add    $0x1,%rbp
cmp    $0x10,%rbp
je     134c <pty+0x22c>
mov    %al,0x2d33(%rip)
mov    %r15,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <open@plt>
mov    %eax,(%rbx)
test   %eax,%eax
js     12f0 <pty+0x1d0>
movzbl 0x0(%rbp,%r13,1),%eax
mov    %al,0x2d1d(%rip)
mov    %r12,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <open@plt>
mov    %eax,(%r14)
test   %eax,%eax
jns    12b6 <pty+0x196>
mov    (%rbx),%edi
xor    %eax,%eax
call   1030 <close@plt>
jmp    12f0 <pty+0x1d0>
xor    %eax,%eax
jmp    12b8 <pty+0x198>

LLVM IR (-O0):
@pty.master = internal global [11 x i8] c"/dev/pty??\00"
@pty.slave = internal global [11 x i8] c"/dev/tty??\00"
@.str = [5 x i8] c"pqrs\00"
@.str.1 = [17 x i8] c"0123456789abcdef\00"
define signext i8 @pty(i32* %0, i32* %1) {
%3 = alloca i8
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
br label %8
8: ; preds = %49, %2
%9 = load i8*, i8** %6
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %52
13: ; preds = %8
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
store i8 %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 1, i64 -3)
%16 = load i8*, i8** %6
%17 = load i8, i8* %16
store i8 %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 1, i64 -3)
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %18
18: ; preds = %45, %13
%19 = load i8*, i8** %7
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %48
23: ; preds = %18
%24 = load i8*, i8** %7
%25 = load i8, i8* %24
store i8 %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 1, i64 -2)
%26 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 0), i32 2)
%27 = load i32*, i32** %4
store i32 %26, i32* %27
%28 = load i32*, i32** %4
%29 = load i32, i32* %28
%30 = icmp sge i32 %29, 0
br i1 %30, label %31, label %44
31: ; preds = %23
%32 = load i8*, i8** %7
%33 = load i8, i8* %32
store i8 %33, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 1, i64 -2)
%34 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 0), i32 2)
%35 = load i32*, i32** %5
store i32 %34, i32* %35
%36 = load i32*, i32** %5
%37 = load i32, i32* %36
%38 = icmp sge i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %31
store i8 1, i8* %3
br label %53
40: ; preds = %31
%41 = load i32*, i32** %4
%42 = load i32, i32* %41
%43 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %42)
br label %44
44: ; preds = %40, %23
br label %45
45: ; preds = %44
%46 = load i8*, i8** %7
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %7
br label %18
48: ; preds = %18
br label %49
49: ; preds = %48
%50 = load i8*, i8** %6
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %6
br label %8
52: ; preds = %8
store i8 0, i8* %3
br label %53
53: ; preds = %52, %39
%54 = load i8, i8* %3
ret i8 %54
}

LLVM IR (-O2):
@pty.master = internal global [11 x i8] c"/dev/pty??\00"
@pty.slave = internal global [11 x i8] c"/dev/tty??\00"
@.str.1 = [17 x i8] c"0123456789abcdef\00"
define signext i8 @pty(i32* nocapture %0, i32* nocapture writeonly %1) {
store i8 112, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 8)
store i8 112, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 8)
br label %3
3: ; preds = %2, %15
%4 = phi i8 [ 48, %2 ], [ %17, %15 ]
%5 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %2 ], [ %16, %15 ]
store i8 %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 9)
%6 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 0), i32 2)
store i32 %6, i32* %0
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %15
8: ; preds = %3
%9 = load i8, i8* %5
store i8 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 9)
%10 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 0), i32 2)
store i32 %10, i32* %1
%11 = icmp sgt i32 %10, -1
br i1 %11, label %70, label %12
12: ; preds = %8
%13 = load i32, i32* %0
%14 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %13)
br label %15
15: ; preds = %3, %12
%16 = getelementptr inbounds i8, i8* %5, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8* %16, getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 16)
br i1 %18, label %19, label %3
19: ; preds = %15
store i8 113, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 8)
store i8 113, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 8)
br label %20
20: ; preds = %32, %19
%21 = phi i8 [ 48, %19 ], [ %34, %32 ]
%22 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %19 ], [ %33, %32 ]
store i8 %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 9)
%23 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 0), i32 2)
store i32 %23, i32* %0
%24 = icmp sgt i32 %23, -1
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load i8, i8* %22
store i8 %26, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 9)
%27 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 0), i32 2)
store i32 %27, i32* %1
%28 = icmp sgt i32 %27, -1
br i1 %28, label %70, label %29
29: ; preds = %25
%30 = load i32, i32* %0
%31 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %30)
br label %32
32: ; preds = %29, %20
%33 = getelementptr inbounds i8, i8* %22, i64 1
%34 = load i8, i8* %33
%35 = icmp eq i8* %33, getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 16)
br i1 %35, label %36, label %20
36: ; preds = %32
store i8 114, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 8)
store i8 114, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 8)
br label %37
37: ; preds = %49, %36
%38 = phi i8 [ 48, %36 ], [ %51, %49 ]
%39 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %36 ], [ %50, %49 ]
store i8 %38, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 9)
%40 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 0), i32 2)
store i32 %40, i32* %0
%41 = icmp sgt i32 %40, -1
br i1 %41, label %42, label %49
42: ; preds = %37
%43 = load i8, i8* %39
store i8 %43, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 9)
%44 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 0), i32 2)
store i32 %44, i32* %1
%45 = icmp sgt i32 %44, -1
br i1 %45, label %70, label %46
46: ; preds = %42
%47 = load i32, i32* %0
%48 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %47)
br label %49
49: ; preds = %46, %37
%50 = getelementptr inbounds i8, i8* %39, i64 1
%51 = load i8, i8* %50
%52 = icmp eq i8* %50, getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 16)
br i1 %52, label %53, label %37
53: ; preds = %49
store i8 115, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 8)
store i8 115, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 8)
br label %54
54: ; preds = %66, %53
%55 = phi i8 [ 48, %53 ], [ %68, %66 ]
%56 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %53 ], [ %67, %66 ]
store i8 %55, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 9)
%57 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.master, i64 0, i64 0), i32 2)
store i32 %57, i32* %0
%58 = icmp sgt i32 %57, -1
br i1 %58, label %59, label %66
59: ; preds = %54
%60 = load i8, i8* %56
store i8 %60, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 9)
%61 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @pty.slave, i64 0, i64 0), i32 2)
store i32 %61, i32* %1
%62 = icmp sgt i32 %61, -1
br i1 %62, label %70, label %63
63: ; preds = %59
%64 = load i32, i32* %0
%65 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %64)
br label %66
66: ; preds = %63, %54
%67 = getelementptr inbounds i8, i8* %56, i64 1
%68 = load i8, i8* %67
%69 = icmp eq i8* %67, getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 16)
br i1 %69, label %70, label %54
70: ; preds = %8, %25, %42, %59, %66
%71 = phi i8 [ 1, %59 ], [ 0, %66 ], [ 1, %42 ], [ 1, %25 ], [ 1, %8 ]
ret i8 %71
}