#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*/ err(int /*<<< orphan*/, char *);
int /*<<< orphan*/ execv(char *, char **);
char *get_home_dir();
char *get_key_path(char const *, char *);
__attribute__((noreturn)) void expunge_keys(char **keys, int count) {
  const char *home_dir = get_home_dir();
  char *args[count + 4];
  int i;
  args[0] = "/usr/bin/ssh-add";
  args[1] = "-d";
  args[2] = "--";
  for (i = 0; i < count; i++)
    args[3 + i] = get_key_path(home_dir, keys[i]);
  args[3 + count] = NULL;
  execv(args[0], args);
  err(EXIT_FAILURE, "failed to launch ssh-add");
}


x86 assembly (clang, -O0):
<expunge_keys>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
call   1050 <get_home_dir@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x20(%rbp)
lea    0xf(,%rcx,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x38(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x28(%rbp)
lea    0xe73(%rip),%rcx
mov    %rcx,(%rax)
lea    0xe7a(%rip),%rcx
mov    %rcx,0x8(%rax)
lea    0xe72(%rip),%rcx
mov    %rcx,0x10(%rax)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f0 <expunge_keys+0xb0>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <get_key_path@plt>
mov    %rax,%rdx
mov    -0x38(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ad <expunge_keys+0x6d>
mov    -0x38(%rbp),%rsi
mov    -0xc(%rbp),%eax
add    $0x3,%eax
cltq
movq   $0x0,(%rsi,%rax,8)
mov    (%rsi),%rdi
call   1060 <execv@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
lea    0xdfb(%rip),%rsi
call   1040 <err@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp

x86 assembly (clang, -O2):
<expunge_keys>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r15
xor    %eax,%eax
call   1050 <get_home_dir@plt>
mov    %rax,%r12
lea    0x4(%rbx),%eax
mov    %rsp,%rcx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rcx,%r13
sub    %rax,%r13
mov    %r13,%rsp
neg    %rax
lea    0xe7e(%rip),%rdx
mov    %rdx,(%rcx,%rax,1)
lea    0xe84(%rip),%rax
mov    %rax,0x8(%r13)
lea    0xe7c(%rip),%rax
mov    %rax,0x10(%r13)
mov    %rbx,-0x30(%rbp)
test   %ebx,%ebx
jle    11ca <expunge_keys+0x8a>
mov    -0x30(%rbp),%ebx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    (%r15,%r14,8),%rsi
mov    %r12,%rdi
call   1030 <get_key_path@plt>
mov    %rax,0x18(%r13,%r14,8)
add    $0x1,%r14
cmp    %r14,%rbx
jne    11b0 <expunge_keys+0x70>
movslq -0x30(%rbp),%rax
movq   $0x0,0x18(%r13,%rax,8)
mov    0x0(%r13),%rdi
mov    %r13,%rsi
call   1060 <execv@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
call   1040 <err@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"/usr/bin/ssh-add\00"
@.str.1 = [3 x i8] c"-d\00"
@.str.2 = [3 x i8] c"--\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [25 x i8] c"failed to launch ssh-add\00"
define void @expunge_keys(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%9 = call i8* (...) @get_home_dir()
store i8* %9, i8** %5
%10 = load i32, i32* %4
%11 = add nsw i32 %10, 4
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8*, i64 %12
store i64 %12, i64* %7
%15 = getelementptr inbounds i8*, i8** %14, i64 0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds i8*, i8** %14, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds i8*, i8** %14, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %17
store i32 0, i32* %8
br label %18
18: ; preds = %34, %2
%19 = load i32, i32* %8
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %37
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = load i8**, i8*** %3
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i8* @get_key_path(i8* %23, i8* %28)
%30 = load i32, i32* %8
%31 = add nsw i32 3, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %14, i64 %32
store i8* %29, i8** %33
br label %34
34: ; preds = %22
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %18
37: ; preds = %18
%38 = load i32, i32* %4
%39 = add nsw i32 3, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %14, i64 %40
store i8* null, i8** %41
%42 = getelementptr inbounds i8*, i8** %14, i64 0
%43 = load i8*, i8** %42
%44 = call i32 @execv(i8* %43, i8** %14)
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @err(i32 %45, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%47 = load i8*, i8** %6
unreachable
}

LLVM IR (-O2):
@.str = [17 x i8] c"/usr/bin/ssh-add\00"
@.str.1 = [3 x i8] c"-d\00"
@.str.2 = [3 x i8] c"--\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [25 x i8] c"failed to launch ssh-add\00"
define void @expunge_keys(i8** nocapture %0, i32 %1) {
%3 = tail call i8* (...) @get_home_dir()
%4 = add nsw i32 %1, 4
%5 = zext i32 %4 to i64
%6 = alloca i8*, i64 %5
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds i8*, i8** %6, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds i8*, i8** %6, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %19, %12 ]
%14 = getelementptr inbounds i8*, i8** %0, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i8* @get_key_path(i8* %3, i8* %15)
%17 = add nuw nsw i64 %13, 3
%18 = getelementptr inbounds i8*, i8** %6, i64 %17
store i8* %16, i8** %18
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %11
br i1 %20, label %21, label %12
21: ; preds = %12, %2
%22 = add nsw i32 %1, 3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %6, i64 %23
store i8* null, i8** %24
%25 = load i8*, i8** %6
%26 = call i32 @execv(i8* %25, i8** %6)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @err(i32 %27, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
unreachable
}