#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 */
struct ttyent {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ _PATH_TTYS;
scalar_t__ change_ttyflags(struct ttyent *);
struct ttyent *getttynam(char *);
int /*<<< orphan*/ warnx(char *, int /*<<< orphan*/, char *);
int change_ttys(char **ttylist) {
  struct ttyent *tep;
  int rval;
  rval = 0;
  for (; *ttylist != NULL; ttylist++) {
    tep = getttynam(*ttylist);
    if (tep == NULL) {
      warnx("couldn't find an entry in %s for \"%s\"", _PATH_TTYS, *ttylist);
      rval = 1;
      continue;
    }
    if (change_ttyflags(tep))
      rval = 1;
  }
  return (rval);
}


x86 assembly (clang, -O0):
<change_ttys>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     11c4 <change_ttys+0x94>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <getttynam@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1194 <change_ttys+0x64>
mov    0x2e75(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
lea    0xe7d(%rip),%rdi
call   1040 <warnx@plt>
movl   $0x1,-0x14(%rbp)
jmp    11b3 <change_ttys+0x83>
mov    -0x10(%rbp),%rdi
call   1050 <change_ttyflags@plt>
cmp    $0x0,%rax
je     11ae <change_ttys+0x7e>
movl   $0x1,-0x14(%rbp)
jmp    11b3 <change_ttys+0x83>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    1143 <change_ttys+0x13>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_ttys>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     119b <change_ttys+0x6b>
add    $0x8,%rbx
xor    %ebp,%ebp
mov    0x2e98(%rip),%r15
lea    0xea9(%rip),%r14
mov    $0x1,%r12d
jmp    117b <change_ttys+0x4b>
nop
mov    %rax,%rdi
call   1050 <change_ttyflags@plt>
test   %rax,%rax
cmovne %r12d,%ebp
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     119d <change_ttys+0x6d>
call   1030 <getttynam@plt>
test   %rax,%rax
jne    1160 <change_ttys+0x30>
mov    (%r15),%esi
mov    -0x8(%rbx),%rdx
mov    %r14,%rdi
call   1040 <warnx@plt>
mov    $0x1,%ebp
jmp    116f <change_ttys+0x3f>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ttyent = type { i32 }
@.str = [38 x i8] c"couldn't find an entry in %s for \22%s\22\00"
@_PATH_TTYS = global i32 0
define i32 @change_ttys(i8** %0) {
%2 = alloca i8**
%3 = alloca %struct.ttyent*
%4 = alloca i32
store i8** %0, i8*** %2
store i32 0, i32* %4
br label %5
5: ; preds = %26, %1
%6 = load i8**, i8*** %2
%7 = load i8*, i8** %6
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %29
9: ; preds = %5
%10 = load i8**, i8*** %2
%11 = load i8*, i8** %10
%12 = call %struct.ttyent* @getttynam(i8* %11)
store %struct.ttyent* %12, %struct.ttyent** %3
%13 = load %struct.ttyent*, %struct.ttyent** %3
%14 = icmp eq %struct.ttyent* %13, null
br i1 %14, label %15, label %20
15: ; preds = %9
%16 = load i32, i32* @_PATH_TTYS
%17 = load i8**, i8*** %2
%18 = load i8*, i8** %17
%19 = call i32 @warnx(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %16, i8* %18)
store i32 1, i32* %4
br label %26
20: ; preds = %9
%21 = load %struct.ttyent*, %struct.ttyent** %3
%22 = call i64 @change_ttyflags(%struct.ttyent* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 1, i32* %4
br label %25
25: ; preds = %24, %20
br label %26
26: ; preds = %25, %15
%27 = load i8**, i8*** %2
%28 = getelementptr inbounds i8*, i8** %27, i32 1
store i8** %28, i8*** %2
br label %5
29: ; preds = %5
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
%struct.ttyent = type { i32 }
@.str = [38 x i8] c"couldn't find an entry in %s for \22%s\22\00"
@_PATH_TTYS = global i32 0
define i32 @change_ttys(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %23, label %4
4: ; preds = %1, %18
%5 = phi i8* [ %21, %18 ], [ %2, %1 ]
%6 = phi i32 [ %19, %18 ], [ 0, %1 ]
%7 = phi i8** [ %20, %18 ], [ %0, %1 ]
%8 = tail call %struct.ttyent* @getttynam(i8* %5)
%9 = icmp eq %struct.ttyent* %8, null
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = load i32, i32* @_PATH_TTYS
%12 = load i8*, i8** %7
%13 = tail call i32 @warnx(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %12)
br label %18
14: ; preds = %4
%15 = tail call i64 @change_ttyflags(%struct.ttyent* %8)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i32 %6, i32 1
br label %18
18: ; preds = %14, %10
%19 = phi i32 [ 1, %10 ], [ %17, %14 ]
%20 = getelementptr inbounds i8*, i8** %7, i64 1
%21 = load i8*, i8** %20
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %4
23: ; preds = %18, %1
%24 = phi i32 [ 0, %1 ], [ %19, %18 ]
ret i32 %24
}