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


x86 assembly (clang, -O0):
<add_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    $0x3,%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)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e5 <add_keys+0xa5>
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    $0x2,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a2 <add_keys+0x62>
mov    -0x38(%rbp),%rsi
mov    -0xc(%rbp),%eax
add    $0x2,%eax
cltq
movq   $0x0,(%rsi,%rax,8)
mov    (%rsi),%rdi
call   1060 <execv@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
call   1040 <err@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp

x86 assembly (clang, -O2):
<add_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    0x3(%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)
mov    %rbx,-0x30(%rbp)
test   %ebx,%ebx
jle    11ba <add_keys+0x7a>
mov    -0x30(%rbp),%ebx
xor    %r14d,%r14d
nop
mov    (%r15,%r14,8),%rsi
mov    %r12,%rdi
call   1030 <get_key_path@plt>
mov    %rax,0x10(%r13,%r14,8)
add    $0x1,%r14
cmp    %r14,%rbx
jne    11a0 <add_keys+0x60>
movslq -0x30(%rbp),%rax
movq   $0x0,0x10(%r13,%rax,8)
mov    0x0(%r13),%rdi
mov    %r13,%rsi
call   1060 <execv@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%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"--\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [25 x i8] c"failed to launch ssh-add\00"
define void @add_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, 3
%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
store i32 0, i32* %8
br label %17
17: ; preds = %33, %2
%18 = load i32, i32* %8
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %36
21: ; preds = %17
%22 = load i8*, i8** %5
%23 = load i8**, i8*** %3
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i8* @get_key_path(i8* %22, i8* %27)
%29 = load i32, i32* %8
%30 = add nsw i32 2, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %14, i64 %31
store i8* %28, i8** %32
br label %33
33: ; preds = %21
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %17
36: ; preds = %17
%37 = load i32, i32* %4
%38 = add nsw i32 2, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %14, i64 %39
store i8* null, i8** %40
%41 = getelementptr inbounds i8*, i8** %14, i64 0
%42 = load i8*, i8** %41
%43 = call i32 @execv(i8* %42, i8** %14)
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @err(i32 %44, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%46 = load i8*, i8** %6
unreachable
}

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