#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 termios {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
char *crypt(char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *fgets(char *, int, int /*<<< orphan*/);
char *get_pass();
char getkey();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ restaure_term(struct termios *);
int /*<<< orphan*/ setsilent(struct termios *);
int /*<<< orphan*/ stdin;
scalar_t__ tcgetattr(int /*<<< orphan*/, struct termios *);
int main() {
  int r;
  char buf[64], *s, *pwd, *pwdCrypt;
  struct termios initial_term;
  char key[2];
  key[0] = getkey();
  key[1] = getkey();
  printf("key = %s\n", (char *)key);
  printf("Tapez votre mot de passe : ");
  if (tcgetattr(0, &initial_term) != 0) {
    perror("get termios");
    exit(EXIT_FAILURE);
  }
  setsilent(&initial_term);
  pwd = get_pass();
  pwdCrypt = crypt(pwd, key);
  printf("Mot de passe chiffre : %s\n", pwdCrypt);
  restaure_term(&initial_term);
  s = fgets(buf, 64, stdin);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <getkey@plt>
mov    %al,-0x72(%rbp)
mov    $0x0,%al
call   1080 <getkey@plt>
mov    %al,-0x71(%rbp)
lea    -0x72(%rbp),%rsi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
lea    -0x70(%rbp),%rsi
call   10a0 <tcgetattr@plt>
cmp    $0x0,%rax
je     1215 <main+0x75>
lea    0xe24(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    -0x70(%rbp),%rdi
call   1070 <setsilent@plt>
mov    $0x0,%al
call   1090 <get_pass@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
lea    -0x72(%rbp),%rsi
call   1040 <crypt@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <restaure_term@plt>
lea    -0x50(%rbp),%rdi
mov    0x2d88(%rip),%rax
mov    (%rax),%edx
mov    $0x40,%esi
call   1060 <fgets@plt>
mov    %rax,-0x58(%rbp)
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
xor    %eax,%eax
call   1080 <getkey@plt>
mov    %al,0x6(%rsp)
xor    %eax,%eax
call   1080 <getkey@plt>
mov    %al,0x7(%rsp)
lea    0xe3e(%rip),%rdi
lea    0x6(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   10a0 <tcgetattr@plt>
test   %rax,%rax
jne    124d <main+0xad>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <setsilent@plt>
xor    %eax,%eax
call   1090 <get_pass@plt>
lea    0x6(%rsp),%rsi
mov    %rax,%rdi
call   1040 <crypt@plt>
lea    0xe1d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <restaure_term@plt>
mov    0x2dba(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
mov    $0x40,%esi
call   1060 <fgets@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    0xdd2(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.termios = type { i32 }
@.str = [10 x i8] c"key = %s\0A\00"
@.str.1 = [28 x i8] c"Tapez votre mot de passe : \00"
@.str.2 = [12 x i8] c"get termios\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [27 x i8] c"Mot de passe chiffre : %s\0A\00"
@stdin = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [64 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.termios
%8 = alloca [2 x i8]
store i32 0, i32* %1
%9 = call signext i8 (...) @getkey()
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
store i8 %9, i8* %10
%11 = call signext i8 (...) @getkey()
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 1
store i8 %11, i8* %12
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%16 = call i64 @tcgetattr(i32 0, %struct.termios* %7)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %0
%19 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %0
%23 = call i32 @setsilent(%struct.termios* %7)
%24 = call i8* (...) @get_pass()
store i8* %24, i8** %5
%25 = load i8*, i8** %5
%26 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%27 = call i8* @crypt(i8* %25, i8* %26)
store i8* %27, i8** %6
%28 = load i8*, i8** %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = call i32 @restaure_term(%struct.termios* %7)
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%32 = load i32, i32* @stdin
%33 = call i8* @fgets(i8* %31, i32 64, i32 %32)
store i8* %33, i8** %4
%34 = load i32, i32* @EXIT_SUCCESS
%35 = call i32 @exit(i32 %34)
unreachable
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@.str = [10 x i8] c"key = %s\0A\00"
@.str.1 = [28 x i8] c"Tapez votre mot de passe : \00"
@.str.2 = [12 x i8] c"get termios\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [27 x i8] c"Mot de passe chiffre : %s\0A\00"
@stdin = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca %struct.termios
%3 = alloca [2 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%5 = bitcast %struct.termios* %2 to i8*
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%7 = tail call signext i8 (...) @getkey()
store i8 %7, i8* %6
%8 = tail call signext i8 (...) @getkey()
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
store i8 %8, i8* %9
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %6)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%12 = call i64 @tcgetattr(i32 0, %struct.termios* %2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %0
%15 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %0
%19 = call i32 @setsilent(%struct.termios* %2)
%20 = call i8* (...) @get_pass()
%21 = call i8* @crypt(i8* %20, i8* %6)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = call i32 @restaure_term(%struct.termios* %2)
%24 = load i32, i32* @stdin
%25 = call i8* @fgets(i8* %4, i32 64, i32 %24)
%26 = load i32, i32* @EXIT_SUCCESS
%27 = call i32 @exit(i32 %26)
unreachable
}