#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 EXIT_FAILURE;
int EXIT_SUCCESS;
char *getpass(char *);
int /*<<< orphan*/ returnstty();
int /*<<< orphan*/ setstty();
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ work(char *, char const *);
int main(int arg, char *args[]) {
  if (arg < 4) {
    return EXIT_FAILURE;
  }
  if (strncmp(args[1], "-u", 2) != 0) {
    return EXIT_FAILURE;
  }
  if (strncmp(args[3], "-p", 2) != 0) {
    return EXIT_FAILURE;
  }
  const char *passwd = getpass("please input password:");
  setstty();
  work(args[2], passwd);
  returnstty();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1181 <main+0x31>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1224 <main+0xd4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe70(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11b5 <main+0x65>
mov    0x2e35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1224 <main+0xd4>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe3f(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11e9 <main+0x99>
mov    0x2e01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1224 <main+0xd4>
lea    0xe16(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <setstty@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <work@plt>
mov    $0x0,%al
call   1060 <returnstty@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2e84(%rip),%rbx
cmp    $0x4,%edi
jl     11c8 <main+0x78>
mov    %rsi,%r15
mov    0x8(%rsi),%rdi
lea    0xe91(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11c8 <main+0x78>
mov    0x18(%r15),%rdi
lea    0xe7a(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11c8 <main+0x78>
lea    0xe67(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1050 <setstty@plt>
mov    0x10(%r15),%rdi
mov    %r14,%rsi
call   1040 <work@plt>
xor    %eax,%eax
call   1060 <returnstty@plt>
mov    0x2e10(%rip),%rbx
mov    (%rbx),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"-u\00"
@.str.1 = [3 x i8] c"-p\00"
@.str.2 = [23 x i8] c"please input password:\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load i32, i32* @EXIT_FAILURE
store i32 %10, i32* %3
br label %37
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strncmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %37
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = load i32, i32* @EXIT_FAILURE
store i32 %26, i32* %3
br label %37
27: ; preds = %19
%28 = call i8* @getpass(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i8* %28, i8** %6
%29 = call i32 (...) @setstty()
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = load i8*, i8** %6
%34 = call i32 @work(i8* %32, i8* %33)
%35 = call i32 (...) @returnstty()
%36 = load i32, i32* @EXIT_SUCCESS
store i32 %36, i32* %3
br label %37
37: ; preds = %27, %25, %17, %9
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"-u\00"
@.str.1 = [3 x i8] c"-p\00"
@.str.2 = [23 x i8] c"please input password:\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %21, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 3
%11 = load i8*, i8** %10
%12 = tail call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = tail call i8* @getpass(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 (...) @setstty()
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32 @work(i8* %18, i8* %15)
%20 = tail call i32 (...) @returnstty()
br label %21
21: ; preds = %9, %4, %2, %14
%22 = phi i32* [ @EXIT_SUCCESS, %14 ], [ @EXIT_FAILURE, %2 ], [ @EXIT_FAILURE, %4 ], [ @EXIT_FAILURE, %9 ]
%23 = load i32, i32* %22
ret i32 %23
}