#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 option {
  char *name;
  int has_arg;
  char val;
  int /*<<< orphan*/ member_0;
};
struct ibv_device {
  int dummy;
};
struct ibv_context {
  int num_comp_vectors;
};

/* Variables and functions */
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
scalar_t__ ibv_close_device(struct ibv_context *);
int /*<<< orphan*/ ibv_free_device_list(struct ibv_device **);
struct ibv_device **ibv_get_device_list(int /*<<< orphan*/ *);
char *ibv_get_device_name(struct ibv_device *);
struct ibv_context *ibv_open_device(struct ibv_device *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
char *strdupa(int /*<<< orphan*/);
int strtol(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  struct ibv_device *ib_dev;
  char *ib_devname = NULL;
  int ib_port = 1;
  while (1) {
    int c;
    static struct option long_options[] = {
        {.name = "ib-dev", .has_arg = 1, .val = 'd'},
        {.name = "ib-port", .has_arg = 1, .val = 'i'},
        {0}};
    c = getopt_long(argc, argv, "d:i:", long_options, NULL);
    if (c == -1)
      break;
    switch (c) {
    case 'd':
      ib_devname = strdupa(optarg);
      break;
    case 'i':
      ib_port = strtol(optarg, NULL, 0);
      if (ib_port < 0) {
        usage(argv[0]);
        return 1;
      }
      break;
    default:
      usage(argv[0]);
      return 1;
    }
  }
  struct ibv_device **dev_list = ibv_get_device_list(NULL);
  if (!dev_list) {
    fprintf(stderr, "Failed to get IB devices list: errnor=%d\n", errno);
    return 1;
  }
  if (!ib_devname) {
    ib_dev = *dev_list;
    if (!ib_dev) {
      fprintf(stderr, "No IB devices found\n");
      return 1;
    }
  } else {
    int i;
    for (i = 0; dev_list[i]; ++i)
      if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname))
        break;
    ib_dev = dev_list[i];
    if (!ib_dev) {
      fprintf(stderr, "IB device %s not found\n", ib_devname);
      return 1;
    }
  }
  struct ibv_context *context = ibv_open_device(ib_dev);
  if (!context) {
    fprintf(stderr, "Couldn't get context for %s: errno=%d\n",
            ibv_get_device_name(ib_dev), errno);
    return 1;
  }
  printf("num_comp_vectors: %d\n", context->num_comp_vectors);
  if (ibv_close_device(context)) {
    fprintf(stderr, "Couldn't release context\n");
    return 1;
  }
  ibv_free_device_list(dev_list);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe1c(%rip),%rdx
lea    0x2e96(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1216 <main+0x56>
jmp    12ad <main+0xed>
mov    -0x28(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x64,%eax
je     123b <main+0x7b>
jmp    122a <main+0x6a>
mov    -0x44(%rbp),%eax
sub    $0x69,%eax
je     1252 <main+0x92>
jmp    1290 <main+0xd0>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   10a0 <strdupa@plt>
mov    %rax,-0x20(%rbp)
jmp    12a8 <main+0xe8>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtol@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    128b <main+0xcb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1487 <main+0x2c7>
jmp    12a8 <main+0xe8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1487 <main+0x2c7>
jmp    11e5 <main+0x25>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <ibv_get_device_list@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12f1 <main+0x131>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
mov    0x2cfb(%rip),%rax
mov    (%rax),%edx
lea    0xd36(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1487 <main+0x2c7>
cmpq   $0x0,-0x20(%rbp)
jne    133a <main+0x17a>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1335 <main+0x175>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
lea    0xd1c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1487 <main+0x2c7>
jmp    13d9 <main+0x219>
movl   $0x0,-0x34(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1392 <main+0x1d2>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10e0 <ibv_get_device_name@plt>
mov    %rax,%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    137f <main+0x1bf>
jmp    1392 <main+0x1d2>
jmp    1384 <main+0x1c4>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1341 <main+0x181>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    13d4 <main+0x214>
mov    0x2c24(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xc92(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1487 <main+0x2c7>
jmp    13d9 <main+0x219>
mov    -0x18(%rbp),%rdi
call   10d0 <ibv_open_device@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    142f <main+0x26f>
mov    0x2be0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   10e0 <ibv_get_device_name@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%rdx
mov    0x2bbd(%rip),%rax
mov    (%rax),%ecx
lea    0xc4f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1487 <main+0x2c7>
mov    -0x40(%rbp),%rax
mov    (%rax),%esi
lea    0xc56(%rip),%rdi
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
call   10b0 <ibv_close_device@plt>
cmp    $0x0,%rax
je     1477 <main+0x2b7>
mov    0x2b7d(%rip),%rax
mov    (%rax),%edi
lea    0xc44(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1487 <main+0x2c7>
mov    -0x30(%rbp),%rdi
call   1090 <ibv_free_device_list@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r15d,%r15d
lea    0xe35(%rip),%r14
lea    0x2eaf(%rip),%r12
mov    0x2e10(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
xor    %r8d,%r8d
call   1030 <getopt_long@plt>
cmp    $0x69,%eax
jne    121b <main+0x5b>
mov    0x0(%r13),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <strtol@plt>
test   %eax,%eax
jns    11f0 <main+0x30>
jmp    1233 <main+0x73>
cmp    $0xffffffff,%eax
je     124f <main+0x8f>
cmp    $0x64,%eax
jne    1233 <main+0x73>
mov    0x0(%r13),%edi
call   10a0 <strdupa@plt>
mov    %rax,%r15
jmp    11f0 <main+0x30>
mov    (%rbx),%rdi
call   10c0 <usage@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1080 <ibv_get_device_list@plt>
test   %rax,%rax
je     12aa <main+0xea>
mov    %rax,%r14
mov    (%rax),%rbx
test   %r15,%r15
je     12cf <main+0x10f>
test   %rbx,%rbx
je     1338 <main+0x178>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10e0 <ibv_get_device_name@plt>
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     12e6 <main+0x126>
mov    0x8(%r14,%rbp,8),%rbx
add    $0x1,%rbp
test   %rbx,%rbx
jne    1280 <main+0xc0>
jmp    1338 <main+0x178>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
mov    0x2d16(%rip),%rax
mov    (%rax),%edx
lea    0xd51(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    123b <main+0x7b>
test   %rbx,%rbx
jne    12f1 <main+0x131>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    0xd5a(%rip),%rsi
jmp    132c <main+0x16c>
mov    %ebp,%eax
mov    (%r14,%rax,8),%rbx
test   %rbx,%rbx
je     1338 <main+0x178>
mov    %rbx,%rdi
call   10d0 <ibv_open_device@plt>
test   %rax,%rax
je     1357 <main+0x197>
mov    %rax,%rbp
mov    (%rax),%esi
lea    0xd88(%rip),%rdi
call   1040 <printf@plt>
mov    %rbp,%rdi
call   10b0 <ibv_close_device@plt>
test   %rax,%rax
je     1389 <main+0x1c9>
mov    0x2cb5(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    123b <main+0x7b>
mov    0x2c99(%rip),%rax
mov    (%rax),%edi
lea    0xd0b(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    123b <main+0x7b>
mov    0x2c7a(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   10e0 <ibv_get_device_name@plt>
mov    0x2c61(%rip),%rcx
mov    (%rcx),%ecx
lea    0xcf3(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    123b <main+0x7b>
mov    %r14,%rdi
call   1090 <ibv_free_device_list@plt>
xor    %eax,%eax
jmp    1240 <main+0x80>

LLVM IR (-O0):
%struct.option = type { i8*, i32, i8, i32 }
%struct.ibv_device = type { i32 }
%struct.ibv_context = type { i32 }
@main.long_options = internal global [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i32 1, i8 100, i32 0 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 1, i8 105, i32 0 }, %struct.option zeroinitializer]
@.str = [7 x i8] c"ib-dev\00"
@.str.1 = [8 x i8] c"ib-port\00"
@.str.2 = [5 x i8] c"d:i:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.3 = [42 x i8] c"Failed to get IB devices list: errnor=%d\0A\00"
@errno = global i32 0
@.str.4 = [21 x i8] c"No IB devices found\0A\00"
@.str.5 = [24 x i8] c"IB device %s not found\0A\00"
@.str.6 = [39 x i8] c"Couldn't get context for %s: errno=%d\0A\00"
@.str.7 = [22 x i8] c"num_comp_vectors: %d\0A\00"
@.str.8 = [26 x i8] c"Couldn't release context\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.ibv_device*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.ibv_device**
%11 = alloca i32
%12 = alloca %struct.ibv_context*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i32 1, i32* %8
br label %13
13: ; preds = %2, %41
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt_long(i32 %14, i8** %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @main.long_options, i64 0, i64 0), i32* null)
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %13
br label %42
20: ; preds = %13
%21 = load i32, i32* %9
switch i32 %21, label %36 [
i32 100, label %22
i32 105, label %25
]
22: ; preds = %20
%23 = load i32, i32* @optarg
%24 = call i8* @strdupa(i32 %23)
store i8* %24, i8** %7
br label %41
25: ; preds = %20
%26 = load i32, i32* @optarg
%27 = call i32 @strtol(i32 %26, i32* null, i32 0)
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 @usage(i8* %33)
store i32 1, i32* %3
br label %123
35: ; preds = %25
br label %41
36: ; preds = %20
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = call i32 @usage(i8* %39)
store i32 1, i32* %3
br label %123
41: ; preds = %35, %22
br label %13
42: ; preds = %19
%43 = call %struct.ibv_device** @ibv_get_device_list(i32* null)
store %struct.ibv_device** %43, %struct.ibv_device*** %10
%44 = load %struct.ibv_device**, %struct.ibv_device*** %10
%45 = icmp ne %struct.ibv_device** %44, null
br i1 %45, label %50, label %46
46: ; preds = %42
%47 = load i32, i32* @stderr
%48 = load i32, i32* @errno
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %48)
store i32 1, i32* %3
br label %123
50: ; preds = %42
%51 = load i8*, i8** %7
%52 = icmp ne i8* %51, null
br i1 %52, label %62, label %53
53: ; preds = %50
%54 = load %struct.ibv_device**, %struct.ibv_device*** %10
%55 = load %struct.ibv_device*, %struct.ibv_device** %54
store %struct.ibv_device* %55, %struct.ibv_device** %6
%56 = load %struct.ibv_device*, %struct.ibv_device** %6
%57 = icmp ne %struct.ibv_device* %56, null
br i1 %57, label %61, label %58
58: ; preds = %53
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %123
61: ; preds = %53
br label %98
62: ; preds = %50
store i32 0, i32* %11
br label %63
63: ; preds = %82, %62
%64 = load %struct.ibv_device**, %struct.ibv_device*** %10
%65 = load i32, i32* %11
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds %struct.ibv_device*, %struct.ibv_device** %64, i64 %66
%68 = load %struct.ibv_device*, %struct.ibv_device** %67
%69 = icmp ne %struct.ibv_device* %68, null
br i1 %69, label %70, label %85
70: ; preds = %63
%71 = load %struct.ibv_device**, %struct.ibv_device*** %10
%72 = load i32, i32* %11
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds %struct.ibv_device*, %struct.ibv_device** %71, i64 %73
%75 = load %struct.ibv_device*, %struct.ibv_device** %74
%76 = call i8* @ibv_get_device_name(%struct.ibv_device* %75)
%77 = load i8*, i8** %7
%78 = call i32 @strcmp(i8* %76, i8* %77)
%79 = icmp ne i32 %78, 0
br i1 %79, label %81, label %80
80: ; preds = %70
br label %85
81: ; preds = %70
br label %82
82: ; preds = %81
%83 = load i32, i32* %11
%84 = add nsw i32 %83, 1
store i32 %84, i32* %11
br label %63
85: ; preds = %80, %63
%86 = load %struct.ibv_device**, %struct.ibv_device*** %10
%87 = load i32, i32* %11
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds %struct.ibv_device*, %struct.ibv_device** %86, i64 %88
%90 = load %struct.ibv_device*, %struct.ibv_device** %89
store %struct.ibv_device* %90, %struct.ibv_device** %6
%91 = load %struct.ibv_device*, %struct.ibv_device** %6
%92 = icmp ne %struct.ibv_device* %91, null
br i1 %92, label %97, label %93
93: ; preds = %85
%94 = load i32, i32* @stderr
%95 = load i8*, i8** %7
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %95)
store i32 1, i32* %3
br label %123
97: ; preds = %85
br label %98
98: ; preds = %97, %61
%99 = load %struct.ibv_device*, %struct.ibv_device** %6
%100 = call %struct.ibv_context* @ibv_open_device(%struct.ibv_device* %99)
store %struct.ibv_context* %100, %struct.ibv_context** %12
%101 = load %struct.ibv_context*, %struct.ibv_context** %12
%102 = icmp ne %struct.ibv_context* %101, null
br i1 %102, label %109, label %103
103: ; preds = %98
%104 = load i32, i32* @stderr
%105 = load %struct.ibv_device*, %struct.ibv_device** %6
%106 = call i8* @ibv_get_device_name(%struct.ibv_device* %105)
%107 = load i32, i32* @errno
%108 = call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* %106, i32 %107)
store i32 1, i32* %3
br label %123
109: ; preds = %98
%110 = load %struct.ibv_context*, %struct.ibv_context** %12
%111 = getelementptr inbounds %struct.ibv_context, %struct.ibv_context* %110, i32 0, i32 0
%112 = load i32, i32* %111
%113 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %112)
%114 = load %struct.ibv_context*, %struct.ibv_context** %12
%115 = call i64 @ibv_close_device(%struct.ibv_context* %114)
%116 = icmp ne i64 %115, 0
br i1 %116, label %117, label %120
117: ; preds = %109
%118 = load i32, i32* @stderr
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %123
120: ; preds = %109
%121 = load %struct.ibv_device**, %struct.ibv_device*** %10
%122 = call i32 @ibv_free_device_list(%struct.ibv_device** %121)
store i32 0, i32* %3
br label %123
123: ; preds = %120, %117, %103, %93, %58, %46, %36, %30
%124 = load i32, i32* %3
ret i32 %124
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i8, i32 }
%struct.ibv_device = type { i32 }
%struct.ibv_context = type { i32 }
@main.long_options = internal global [3 x %struct.option] [%struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i32 1, i8 100, i32 0 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 1, i8 105, i32 0 }, %struct.option zeroinitializer]
@.str = [7 x i8] c"ib-dev\00"
@.str.1 = [8 x i8] c"ib-port\00"
@.str.2 = [5 x i8] c"d:i:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.3 = [42 x i8] c"Failed to get IB devices list: errnor=%d\0A\00"
@errno = global i32 0
@.str.4 = [21 x i8] c"No IB devices found\0A\00"
@.str.5 = [24 x i8] c"IB device %s not found\0A\00"
@.str.6 = [39 x i8] c"Couldn't get context for %s: errno=%d\0A\00"
@.str.7 = [22 x i8] c"num_comp_vectors: %d\0A\00"
@.str.8 = [26 x i8] c"Couldn't release context\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %7, %2
%4 = phi i8* [ %9, %7 ], [ null, %2 ]
br label %5
5: ; preds = %3, %10
%6 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([3 x %struct.option], [3 x %struct.option]* @main.long_options, i64 0, i64 0), i32* null)
switch i32 %6, label %17 [
i32 -1, label %20
i32 100, label %7
i32 105, label %10
]
7: ; preds = %5
%8 = load i32, i32* @optarg
%9 = tail call i8* @strdupa(i32 %8)
br label %3
10: ; preds = %5
%11 = load i32, i32* @optarg
%12 = tail call i32 @strtol(i32 %11, i32* null, i32 0)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %10
%15 = load i8*, i8** %1
%16 = tail call i32 @usage(i8* %15)
br label %78
17: ; preds = %5
%18 = load i8*, i8** %1
%19 = tail call i32 @usage(i8* %18)
br label %78
20: ; preds = %5
%21 = tail call %struct.ibv_device** @ibv_get_device_list(i32* null)
%22 = icmp eq %struct.ibv_device** %21, null
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = load i32, i32* @errno
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %78
27: ; preds = %20
%28 = icmp eq i8* %4, null
%29 = load %struct.ibv_device*, %struct.ibv_device** %21
%30 = icmp eq %struct.ibv_device* %29, null
br i1 %28, label %32, label %31
31: ; preds = %27
br i1 %30, label %55, label %36
32: ; preds = %27
br i1 %30, label %33, label %58
33: ; preds = %32
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %78
36: ; preds = %31, %42
%37 = phi i64 [ %43, %42 ], [ 0, %31 ]
%38 = phi %struct.ibv_device* [ %45, %42 ], [ %29, %31 ]
%39 = tail call i8* @ibv_get_device_name(%struct.ibv_device* %38)
%40 = tail call i32 @strcmp(i8* dereferenceable(1) %39, i8* %4)
%41 = icmp eq i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %36
%43 = add nuw i64 %37, 1
%44 = getelementptr inbounds %struct.ibv_device*, %struct.ibv_device** %21, i64 %43
%45 = load %struct.ibv_device*, %struct.ibv_device** %44
%46 = icmp eq %struct.ibv_device* %45, null
br i1 %46, label %55, label %36
47: ; preds = %36
%48 = and i64 %37, 4294967295
%49 = getelementptr inbounds %struct.ibv_device*, %struct.ibv_device** %21, i64 %48
%50 = load %struct.ibv_device*, %struct.ibv_device** %49
%51 = icmp eq %struct.ibv_device* %50, null
br i1 %51, label %52, label %58
52: ; preds = %47
%53 = load i32, i32* @stderr
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br label %78
55: ; preds = %42, %31
%56 = load i32, i32* @stderr
%57 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br label %78
58: ; preds = %47, %32
%59 = phi %struct.ibv_device* [ %29, %32 ], [ %50, %47 ]
%60 = tail call %struct.ibv_context* @ibv_open_device(%struct.ibv_device* %59)
%61 = icmp eq %struct.ibv_context* %60, null
br i1 %61, label %62, label %67
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = tail call i8* @ibv_get_device_name(%struct.ibv_device* %59)
%65 = load i32, i32* @errno
%66 = tail call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* %64, i32 %65)
br label %78
67: ; preds = %58
%68 = getelementptr inbounds %struct.ibv_context, %struct.ibv_context* %60, i64 0, i32 0
%69 = load i32, i32* %68
%70 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %69)
%71 = tail call i64 @ibv_close_device(%struct.ibv_context* %60)
%72 = icmp eq i64 %71, 0
br i1 %72, label %76, label %73
73: ; preds = %67
%74 = load i32, i32* @stderr
%75 = tail call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
br label %78
76: ; preds = %67
%77 = tail call i32 @ibv_free_device_list(%struct.ibv_device** %21)
br label %78
78: ; preds = %14, %17, %55, %52, %23, %33, %76, %73, %62
%79 = phi i32 [ 1, %55 ], [ 1, %33 ], [ 1, %23 ], [ 1, %73 ], [ 0, %76 ], [ 1, %62 ], [ 1, %52 ], [ 1, %17 ], [ 1, %14 ]
ret i32 %79
}