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

/* Variables and functions */
int /*<<< orphan*/ execvp(char const *, void *);
int /*<<< orphan*/ perror(char *);
scalar_t__ set_cpu_affinity(unsigned long);
unsigned long strtoul(char const *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int runon(int argc, const char *argv[], const struct cmd_info *info) {
  unsigned long cpu;
  argc--;
  argv++;
  cpu = strtoul(argv[0], NULL, 0);
  argc--;
  argv++;
  if (set_cpu_affinity(cpu) < 0) {
    return -1;
  }
  execvp(argv[0], (void *)argv);
  perror("exec");
  return -1;
}


x86 assembly (clang, -O0):
<runon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <set_cpu_affinity@plt>
cmp    $0x0,%rax
jge    11b2 <runon+0x72>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <runon+0x95>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <execvp@plt>
lea    0xe37(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runon>:
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %rax,%rdi
call   1030 <set_cpu_affinity@plt>
test   %rax,%rax
jns    1165 <runon+0x25>
mov    $0xffffffff,%eax
pop    %rbx
ret
add    $0x10,%rbx
mov    (%rbx),%rdi
mov    %rbx,%rsi
call   1060 <execvp@plt>
lea    0xe85(%rip),%rdi
call   1040 <perror@plt>
jmp    115e <runon+0x1e>

LLVM IR (-O0):
%struct.cmd_info = type { i32 }
@.str = [5 x i8] c"exec\00"
define i32 @runon(i32 %0, i8** %1, %struct.cmd_info* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca %struct.cmd_info*
%8 = alloca i64
store i32 %0, i32* %5
store i8** %1, i8*** %6
store %struct.cmd_info* %2, %struct.cmd_info** %7
%9 = load i32, i32* %5
%10 = add nsw i32 %9, -1
store i32 %10, i32* %5
%11 = load i8**, i8*** %6
%12 = getelementptr inbounds i8*, i8** %11, i32 1
store i8** %12, i8*** %6
%13 = load i8**, i8*** %6
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i64 @strtoul(i8* %15, i32* null, i32 0)
store i64 %16, i64* %8
%17 = load i32, i32* %5
%18 = add nsw i32 %17, -1
store i32 %18, i32* %5
%19 = load i8**, i8*** %6
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %6
%21 = load i64, i64* %8
%22 = call i64 @set_cpu_affinity(i64 %21)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %3
store i32 -1, i32* %4
br label %33
25: ; preds = %3
%26 = load i8**, i8*** %6
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %6
%30 = bitcast i8** %29 to i8*
%31 = call i32 @execvp(i8* %28, i8* %30)
%32 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %33
33: ; preds = %25, %24
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
%struct.cmd_info = type { i32 }
@.str = [5 x i8] c"exec\00"
define i32 @runon(i32 %0, i8** %1, %struct.cmd_info* nocapture readnone %2) {
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @strtoul(i8* nocapture %5, i32* null, i32 0)
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = tail call i64 @set_cpu_affinity(i64 %6)
%9 = icmp slt i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %3
%11 = load i8*, i8** %7
%12 = bitcast i8** %7 to i8*
%13 = tail call i32 @execvp(i8* %11, i8* %12)
%14 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %3, %10
ret i32 -1
}