#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ PR_SET_NAME;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
scalar_t__ prctl(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
char *strerror(int /*<<< orphan*/);
int strlen(char *);
void passphrase_mask(int argc, char *argv[], int argc_mask) {
  int i, argl = 0;
  char *argv_mask;
  for (i = 0; i < strlen(argv[argc_mask]); i++) {
    argv[argc_mask][i] = '*';
  }
  for (i = 0; i < argc; i++)
    argl = argl + strlen(argv[i]);
  if ((argv_mask = (char *)malloc((argl + argc + 10) * sizeof(char))) == NULL) {
    fprintf(stderr, "Unable to allocate memory: %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  argv_mask[0] = '\0';
  for (i = 0; i < argc; i++) {
    strcat(argv_mask, argv[i]);
    strcat(argv_mask, " ");
  }
  if (prctl(PR_SET_NAME, argv_mask) < 0) {
    fprintf(stderr, "Unable to rename progress: %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  free(argv_mask);
}


x86 assembly (clang, -O0):
<passphrase_mask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    11e6 <passphrase_mask+0x66>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movb   $0x2a,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a0 <passphrase_mask+0x20>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1228 <passphrase_mask+0xa8>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ed <passphrase_mask+0x6d>
mov    -0x1c(%rbp),%eax
add    -0x4(%rbp),%eax
add    $0xa,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1286 <passphrase_mask+0x106>
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xd8d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12d3 <passphrase_mask+0x153>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1080 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xd5f(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1294 <passphrase_mask+0x114>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rsi
call   1060 <prctl@plt>
cmp    $0x0,%rax
jge    1329 <passphrase_mask+0x1a9>
mov    0x2cea(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x38(%rbp),%edi
mov    %rax,%rdx
lea    0xd0b(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<passphrase_mask>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %edi,%r14d
movslq %edx,%r12
mov    (%rsi,%r12,8),%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11cc <passphrase_mask+0x4c>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%r12,8),%rax
movb   $0x2a,(%rax,%rbx,1)
add    $0x1,%rbx
mov    (%r15,%r12,8),%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11b0 <passphrase_mask+0x30>
mov    %r14d,%r12d
test   %r14d,%r14d
jle    11f7 <passphrase_mask+0x77>
xor    %ebx,%ebx
xor    %r13d,%r13d
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rdi
call   1040 <strlen@plt>
add    %eax,%r13d
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11e0 <passphrase_mask+0x60>
jmp    11fa <passphrase_mask+0x7a>
xor    %r13d,%r13d
lea    (%r14,%r13,1),%edi
add    $0xa,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     1267 <passphrase_mask+0xe7>
mov    %rax,%r13
movb   $0x0,(%rax)
test   %r14d,%r14d
jle    1240 <passphrase_mask+0xc0>
xor    %ebx,%ebx
lea    0xe00(%rip),%r14
nop
mov    (%r15,%rbx,8),%rsi
mov    %r13,%rdi
call   1080 <strcat@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1220 <passphrase_mask+0xa0>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
mov    %r13,%rsi
call   1060 <prctl@plt>
test   %rax,%rax
js     1287 <passphrase_mask+0x107>
mov    %r13,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%ebx
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd7b(%rip),%rsi
jmp    12a5 <passphrase_mask+0x125>
mov    0x2d52(%rip),%rax
mov    (%rax),%ebx
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd7c(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Unable to allocate memory: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c" \00"
@PR_SET_NAME = global i32 0
@.str.2 = [31 x i8] c"Unable to rename progress: %s\0A\00"
define void @passphrase_mask(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
store i32 0, i32* %8
store i32 0, i32* %7
br label %10
10: ; preds = %28, %3
%11 = load i32, i32* %7
%12 = load i8**, i8*** %5
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
%18 = icmp slt i32 %11, %17
br i1 %18, label %19, label %31
19: ; preds = %10
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 42, i8* %27
br label %28
28: ; preds = %19
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %10
31: ; preds = %10
store i32 0, i32* %7
br label %32
32: ; preds = %45, %31
%33 = load i32, i32* %7
%34 = load i32, i32* %4
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %48
36: ; preds = %32
%37 = load i32, i32* %8
%38 = load i8**, i8*** %5
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @strlen(i8* %42)
%44 = add nsw i32 %37, %43
store i32 %44, i32* %8
br label %45
45: ; preds = %36
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %32
48: ; preds = %32
%49 = load i32, i32* %8
%50 = load i32, i32* %4
%51 = add nsw i32 %49, %50
%52 = add nsw i32 %51, 10
%53 = sext i32 %52 to i64
%54 = mul i64 %53, 1
%55 = trunc i64 %54 to i32
%56 = call i64 @malloc(i32 %55)
%57 = inttoptr i64 %56 to i8*
store i8* %57, i8** %9
%58 = icmp eq i8* %57, null
br i1 %58, label %59, label %66
59: ; preds = %48
%60 = load i32, i32* @stderr
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %62)
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %48
%67 = load i8*, i8** %9
%68 = getelementptr inbounds i8, i8* %67, i64 0
store i8 0, i8* %68
store i32 0, i32* %7
br label %69
69: ; preds = %83, %66
%70 = load i32, i32* %7
%71 = load i32, i32* %4
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %86
73: ; preds = %69
%74 = load i8*, i8** %9
%75 = load i8**, i8*** %5
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8*, i8** %75, i64 %77
%79 = load i8*, i8** %78
%80 = call i32 @strcat(i8* %74, i8* %79)
%81 = load i8*, i8** %9
%82 = call i32 @strcat(i8* %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %83
83: ; preds = %73
%84 = load i32, i32* %7
%85 = add nsw i32 %84, 1
store i32 %85, i32* %7
br label %69
86: ; preds = %69
%87 = load i32, i32* @PR_SET_NAME
%88 = load i8*, i8** %9
%89 = call i64 @prctl(i32 %87, i8* %88)
%90 = icmp slt i64 %89, 0
br i1 %90, label %91, label %98
91: ; preds = %86
%92 = load i32, i32* @stderr
%93 = load i32, i32* @errno
%94 = call i8* @strerror(i32 %93)
%95 = call i32 @fprintf(i32 %92, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %94)
%96 = load i32, i32* @EXIT_FAILURE
%97 = call i32 @exit(i32 %96)
unreachable
98: ; preds = %86
%99 = load i8*, i8** %9
%100 = call i32 @free(i8* %99)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Unable to allocate memory: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c" \00"
@PR_SET_NAME = global i32 0
@.str.2 = [31 x i8] c"Unable to rename progress: %s\0A\00"
define void @passphrase_mask(i32 %0, i8** nocapture %1, i32 %2) {
%4 = sext i32 %2 to i64
%5 = getelementptr inbounds i8*, i8** %1, i64 %4
%6 = load i8*, i8** %5
%7 = tail call i32 @strlen(i8* %6)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %13, %3
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %31
11: ; preds = %9
%12 = zext i32 %0 to i64
br label %22
13: ; preds = %3, %13
%14 = phi i64 [ %17, %13 ], [ 0, %3 ]
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 %14
store i8 42, i8* %16
%17 = add nuw nsw i64 %14, 1
%18 = load i8*, i8** %5
%19 = tail call i32 @strlen(i8* %18)
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %17, %20
br i1 %21, label %13, label %9
22: ; preds = %11, %22
%23 = phi i64 [ 0, %11 ], [ %29, %22 ]
%24 = phi i32 [ 0, %11 ], [ %28, %22 ]
%25 = getelementptr inbounds i8*, i8** %1, i64 %23
%26 = load i8*, i8** %25
%27 = tail call i32 @strlen(i8* %26)
%28 = add nsw i32 %27, %24
%29 = add nuw nsw i64 %23, 1
%30 = icmp eq i64 %29, %12
br i1 %30, label %31, label %22
31: ; preds = %22, %9
%32 = phi i32 [ 0, %9 ], [ %28, %22 ]
%33 = add i32 %0, 10
%34 = add i32 %33, %32
%35 = tail call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to i8*
%37 = icmp eq i64 %35, 0
br i1 %37, label %38, label %45
38: ; preds = %31
%39 = load i32, i32* @stderr
%40 = load i32, i32* @errno
%41 = tail call i8* @strerror(i32 %40)
%42 = tail call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %41)
%43 = load i32, i32* @EXIT_FAILURE
%44 = tail call i32 @exit(i32 %43)
unreachable
45: ; preds = %31
store i8 0, i8* %36
br i1 %10, label %46, label %56
46: ; preds = %45
%47 = zext i32 %0 to i64
br label %48
48: ; preds = %46, %48
%49 = phi i64 [ 0, %46 ], [ %54, %48 ]
%50 = getelementptr inbounds i8*, i8** %1, i64 %49
%51 = load i8*, i8** %50
%52 = tail call i32 @strcat(i8* %36, i8* %51)
%53 = tail call i32 @strcat(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%54 = add nuw nsw i64 %49, 1
%55 = icmp eq i64 %54, %47
br i1 %55, label %56, label %48
56: ; preds = %48, %45
%57 = load i32, i32* @PR_SET_NAME
%58 = tail call i64 @prctl(i32 %57, i8* %36)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %67
60: ; preds = %56
%61 = load i32, i32* @stderr
%62 = load i32, i32* @errno
%63 = tail call i8* @strerror(i32 %62)
%64 = tail call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %63)
%65 = load i32, i32* @EXIT_FAILURE
%66 = tail call i32 @exit(i32 %65)
unreachable
67: ; preds = %56
%68 = tail call i32 @free(i8* %36)
ret void
}