#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 atoi(char *);
int getimpstr(char *, int *, char *);
int import_error();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int parse_import(char *s, char *soname, char *sofun, int *n, char *vname,
                 int *m, char *tname[50]) {
  char temp[256];
  int j;
  char c;
  int i = 0;
  int done = 1;
  while (done > 0) {
    c = s[i];
    i++;
    if (c == '(')
      done = 0;
  }
  j = getimpstr(s, &i, temp);
  strcpy(soname, temp);
  if (j == 1)
    return (import_error());
  j = getimpstr(s, &i, temp);
  strcpy(sofun, temp);
  if (j == 1)
    return (import_error());
  j = getimpstr(s, &i, temp);
  *n = atoi(temp);
  if (j == 1 || *n <= 0)
    return (import_error());
  j = getimpstr(s, &i, temp);
  strcpy(vname, temp);
  *m = 0;
  if (j == 1) {
    printf("No weights....\n");
    return (1);
  }
  done = 1;
  while (done > 0) {
    j = getimpstr(s, &i, temp);
    strcpy(tname[*m], temp);
    *m = *m + 1;
    if (j == 1)
      done = 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<parse_import>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movl   $0x0,-0x14c(%rbp)
movl   $0x1,-0x150(%rbp)
cmpl   $0x0,-0x150(%rbp)
jle    11da <parse_import+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x14c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x145(%rbp)
mov    -0x14c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14c(%rbp)
movsbl -0x145(%rbp),%eax
cmp    $0x28,%eax
jne    11d5 <parse_import+0x85>
movl   $0x0,-0x150(%rbp)
jmp    118b <parse_import+0x3b>
mov    -0x10(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    -0x14c(%rbp),%rsi
call   1040 <getimpstr@plt>
mov    %eax,-0x144(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x140(%rbp),%rsi
call   1030 <strcpy@plt>
cmpl   $0x1,-0x144(%rbp)
jne    1223 <parse_import+0xd3>
mov    $0x0,%al
call   1060 <import_error@plt>
mov    %eax,-0x4(%rbp)
jmp    13a3 <parse_import+0x253>
mov    -0x10(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    -0x14c(%rbp),%rsi
call   1040 <getimpstr@plt>
mov    %eax,-0x144(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x140(%rbp),%rsi
call   1030 <strcpy@plt>
cmpl   $0x1,-0x144(%rbp)
jne    126c <parse_import+0x11c>
mov    $0x0,%al
call   1060 <import_error@plt>
mov    %eax,-0x4(%rbp)
jmp    13a3 <parse_import+0x253>
mov    -0x10(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    -0x14c(%rbp),%rsi
call   1040 <getimpstr@plt>
mov    %eax,-0x144(%rbp)
lea    -0x140(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x1,-0x144(%rbp)
je     12b7 <parse_import+0x167>
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jg     12c6 <parse_import+0x176>
mov    $0x0,%al
call   1060 <import_error@plt>
mov    %eax,-0x4(%rbp)
jmp    13a3 <parse_import+0x253>
mov    -0x10(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    -0x14c(%rbp),%rsi
call   1040 <getimpstr@plt>
mov    %eax,-0x144(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x140(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x1,-0x144(%rbp)
jne    1322 <parse_import+0x1d2>
lea    0xcef(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a3 <parse_import+0x253>
movl   $0x1,-0x150(%rbp)
cmpl   $0x0,-0x150(%rbp)
jle    139c <parse_import+0x24c>
mov    -0x10(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    -0x14c(%rbp),%rsi
call   1040 <getimpstr@plt>
mov    %eax,-0x144(%rbp)
mov    0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x140(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x1,-0x144(%rbp)
jne    1397 <parse_import+0x247>
movl   $0x0,-0x150(%rbp)
jmp    132c <parse_import+0x1dc>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_import>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %r9,%r14
mov    %r8,0x10(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
xor    %eax,%eax
nopl   0x0(%rax)
cmpb   $0x28,(%rbx,%rax,1)
lea    0x1(%rax),%rax
jne    1180 <parse_import+0x30>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rsi
lea    0x20(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rdx
call   1050 <getimpstr@plt>
mov    %eax,%r12d
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
cmp    $0x1,%r12d
je     124f <parse_import+0xff>
lea    0xc(%rsp),%rsi
lea    0x20(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rdx
call   1050 <getimpstr@plt>
mov    %eax,%ebp
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
cmp    $0x1,%ebp
je     124f <parse_import+0xff>
lea    0xc(%rsp),%rsi
lea    0x20(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rdx
call   1050 <getimpstr@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1070 <atoi@plt>
mov    0x18(%rsp),%rcx
mov    %eax,(%rcx)
cmp    $0x1,%ebp
je     124f <parse_import+0xff>
test   %eax,%eax
jle    124f <parse_import+0xff>
lea    0xc(%rsp),%rsi
lea    0x20(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rdx
call   1050 <getimpstr@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
movl   $0x0,(%r14)
cmp    $0x1,%ebp
jne    1268 <parse_import+0x118>
lea    0xdb8(%rip),%rdi
call   1040 <puts@plt>
jmp    12a9 <parse_import+0x159>
xor    %eax,%eax
call   1060 <import_error@plt>
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc(%rsp),%r15
lea    0x20(%rsp),%r12
mov    0x160(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <getimpstr@plt>
mov    %eax,%ebp
movslq (%r14),%rax
mov    0x0(%r13,%rax,8),%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
addl   $0x1,(%r14)
cmp    $0x1,%ebp
jne    1280 <parse_import+0x130>
mov    $0x1,%eax
jmp    1256 <parse_import+0x106>

LLVM IR (-O0):
@.str = [16 x i8] c"No weights....\0A\00"
define i32 @parse_import(i8* %0, i8* %1, i8* %2, i32* %3, i8* %4, i32* %5, i8** %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca i8**
%16 = alloca [256 x i8]
%17 = alloca i32
%18 = alloca i8
%19 = alloca i32
%20 = alloca i32
store i8* %0, i8** %9
store i8* %1, i8** %10
store i8* %2, i8** %11
store i32* %3, i32** %12
store i8* %4, i8** %13
store i32* %5, i32** %14
store i8** %6, i8*** %15
store i32 0, i32* %19
store i32 1, i32* %20
br label %21
21: ; preds = %36, %7
%22 = load i32, i32* %20
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %37
24: ; preds = %21
%25 = load i8*, i8** %9
%26 = load i32, i32* %19
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
store i8 %29, i8* %18
%30 = load i32, i32* %19
%31 = add nsw i32 %30, 1
store i32 %31, i32* %19
%32 = load i8, i8* %18
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 40
br i1 %34, label %35, label %36
35: ; preds = %24
store i32 0, i32* %20
br label %36
36: ; preds = %35, %24
br label %21
37: ; preds = %21
%38 = load i8*, i8** %9
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%40 = call i32 @getimpstr(i8* %38, i32* %19, i8* %39)
store i32 %40, i32* %17
%41 = load i8*, i8** %10
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%43 = call i32 @strcpy(i8* %41, i8* %42)
%44 = load i32, i32* %17
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %48
46: ; preds = %37
%47 = call i32 (...) @import_error()
store i32 %47, i32* %8
br label %111
48: ; preds = %37
%49 = load i8*, i8** %9
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%51 = call i32 @getimpstr(i8* %49, i32* %19, i8* %50)
store i32 %51, i32* %17
%52 = load i8*, i8** %11
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%54 = call i32 @strcpy(i8* %52, i8* %53)
%55 = load i32, i32* %17
%56 = icmp eq i32 %55, 1
br i1 %56, label %57, label %59
57: ; preds = %48
%58 = call i32 (...) @import_error()
store i32 %58, i32* %8
br label %111
59: ; preds = %48
%60 = load i8*, i8** %9
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%62 = call i32 @getimpstr(i8* %60, i32* %19, i8* %61)
store i32 %62, i32* %17
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%64 = call i32 @atoi(i8* %63)
%65 = load i32*, i32** %12
store i32 %64, i32* %65
%66 = load i32, i32* %17
%67 = icmp eq i32 %66, 1
br i1 %67, label %72, label %68
68: ; preds = %59
%69 = load i32*, i32** %12
%70 = load i32, i32* %69
%71 = icmp sle i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %68, %59
%73 = call i32 (...) @import_error()
store i32 %73, i32* %8
br label %111
74: ; preds = %68
%75 = load i8*, i8** %9
%76 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%77 = call i32 @getimpstr(i8* %75, i32* %19, i8* %76)
store i32 %77, i32* %17
%78 = load i8*, i8** %13
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%80 = call i32 @strcpy(i8* %78, i8* %79)
%81 = load i32*, i32** %14
store i32 0, i32* %81
%82 = load i32, i32* %17
%83 = icmp eq i32 %82, 1
br i1 %83, label %84, label %86
84: ; preds = %74
%85 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %8
br label %111
86: ; preds = %74
store i32 1, i32* %20
br label %87
87: ; preds = %109, %86
%88 = load i32, i32* %20
%89 = icmp sgt i32 %88, 0
br i1 %89, label %90, label %110
90: ; preds = %87
%91 = load i8*, i8** %9
%92 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%93 = call i32 @getimpstr(i8* %91, i32* %19, i8* %92)
store i32 %93, i32* %17
%94 = load i8**, i8*** %15
%95 = load i32*, i32** %14
%96 = load i32, i32* %95
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8*, i8** %94, i64 %97
%99 = load i8*, i8** %98
%100 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%101 = call i32 @strcpy(i8* %99, i8* %100)
%102 = load i32*, i32** %14
%103 = load i32, i32* %102
%104 = add nsw i32 %103, 1
%105 = load i32*, i32** %14
store i32 %104, i32* %105
%106 = load i32, i32* %17
%107 = icmp eq i32 %106, 1
br i1 %107, label %108, label %109
108: ; preds = %90
store i32 0, i32* %20
br label %109
109: ; preds = %108, %90
br label %87
110: ; preds = %87
store i32 1, i32* %8
br label %111
111: ; preds = %110, %84, %72, %57, %46
%112 = load i32, i32* %8
ret i32 %112
}

LLVM IR (-O2):
@str = [15 x i8] c"No weights....\00"
define i32 @parse_import(i8* %0, i8* %1, i8* %2, i32* nocapture writeonly %3, i8* %4, i32* nocapture %5, i8** nocapture %6) {
%8 = alloca [256 x i8]
%9 = alloca i32
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%11 = bitcast i32* %9 to i8*
br label %12
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %16, %12 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = add nuw i64 %13, 1
%17 = icmp eq i8 %15, 40
br i1 %17, label %18, label %12
18: ; preds = %12
%19 = trunc i64 %16 to i32
store i32 %19, i32* %9
%20 = call i32 @getimpstr(i8* %0, i32* %9, i8* %10)
%21 = call i32 @strcpy(i8* %1, i8* %10)
%22 = icmp eq i32 %20, 1
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 (...) @import_error()
br label %55
25: ; preds = %18
%26 = call i32 @getimpstr(i8* %0, i32* %9, i8* %10)
%27 = call i32 @strcpy(i8* %2, i8* %10)
%28 = icmp eq i32 %26, 1
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 (...) @import_error()
br label %55
31: ; preds = %25
%32 = call i32 @getimpstr(i8* %0, i32* %9, i8* %10)
%33 = call i32 @atoi(i8* %10)
store i32 %33, i32* %3
%34 = icmp eq i32 %32, 1
%35 = icmp slt i32 %33, 1
%36 = select i1 %34, i1 true, i1 %35
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = call i32 (...) @import_error()
br label %55
39: ; preds = %31
%40 = call i32 @getimpstr(i8* %0, i32* %9, i8* %10)
%41 = call i32 @strcpy(i8* %4, i8* %10)
store i32 0, i32* %5
%42 = icmp eq i32 %40, 1
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %55
45: ; preds = %39, %45
%46 = call i32 @getimpstr(i8* %0, i32* %9, i8* %10)
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %6, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @strcpy(i8* %50, i8* %10)
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
%54 = icmp eq i32 %46, 1
br i1 %54, label %55, label %45
55: ; preds = %45, %43, %37, %29, %23
%56 = phi i32 [ %24, %23 ], [ %30, %29 ], [ %38, %37 ], [ 1, %43 ], [ 1, %45 ]
ret i32 %56
}