#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 */
char *fm_read(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *strchr(char *, char);
char *strstr(char *, char *);
int fm_team_info(char *team_name, char *pin_code) {
  char *tmp, *end, *data;
  data = fm_read("probe.team");
  if (data == NULL)
    return -1;
  tmp = strstr(data, "team_name:");
  if (tmp == NULL) {
    do {
      if ((data) != NULL) {
        free(data);
        (data) = NULL;
      }
    } while (0);
    return -1;
  }
  tmp += 10;
  end = strchr(tmp, ';');
  if (end == NULL) {
    do {
      if ((data) != NULL) {
        free(data);
        (data) = NULL;
      }
    } while (0);
    return -1;
  }
  memcpy(team_name, tmp, end - tmp);
  team_name[end - tmp + 1] = '\0';
  tmp = strstr(data, "pin_code:");
  if (tmp == NULL) {
    do {
      if ((data) != NULL) {
        free(data);
        (data) = NULL;
      }
    } while (0);
    return -1;
  }
  tmp += 9;
  end = strchr(tmp, ';');
  if (end == NULL) {
    do {
      if ((data) != NULL) {
        free(data);
        (data) = NULL;
      }
    } while (0);
    return -1;
  }
  memcpy(pin_code, tmp, end - tmp);
  pin_code[end - tmp + 1] = '\0';
  do {
    if ((data) != NULL) {
      free(data);
      (data) = NULL;
    }
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<fm_team_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xe99(%rip),%rdi
call   1040 <fm_read@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1187 <fm_team_info+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    1363 <fm_team_info+0x213>
mov    -0x30(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d8 <fm_team_info+0x88>
jmp    11ab <fm_team_info+0x5b>
cmpq   $0x0,-0x30(%rbp)
je     11c7 <fm_team_info+0x77>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
jmp    11cc <fm_team_info+0x7c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1363 <fm_team_info+0x213>
mov    -0x20(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1233 <fm_team_info+0xe3>
jmp    1206 <fm_team_info+0xb6>
cmpq   $0x0,-0x30(%rbp)
je     1222 <fm_team_info+0xd2>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
jmp    1227 <fm_team_info+0xd7>
movl   $0xffffffff,-0x4(%rbp)
jmp    1363 <fm_team_info+0x213>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,0x1(%rax,%rcx,1)
mov    -0x30(%rbp),%rdi
lea    0xdaa(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12b2 <fm_team_info+0x162>
jmp    1285 <fm_team_info+0x135>
cmpq   $0x0,-0x30(%rbp)
je     12a1 <fm_team_info+0x151>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
jmp    12a6 <fm_team_info+0x156>
movl   $0xffffffff,-0x4(%rbp)
jmp    1363 <fm_team_info+0x213>
mov    -0x20(%rbp),%rax
add    $0x9,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    130d <fm_team_info+0x1bd>
jmp    12e0 <fm_team_info+0x190>
cmpq   $0x0,-0x30(%rbp)
je     12fc <fm_team_info+0x1ac>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
jmp    1301 <fm_team_info+0x1b1>
movl   $0xffffffff,-0x4(%rbp)
jmp    1363 <fm_team_info+0x213>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,0x1(%rax,%rcx,1)
cmpq   $0x0,-0x30(%rbp)
je     1357 <fm_team_info+0x207>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
jmp    135c <fm_team_info+0x20c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fm_team_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xe98(%rip),%rdi
call   1040 <fm_read@plt>
test   %rax,%rax
je     1219 <fm_team_info+0xc9>
mov    %rax,%r13
lea    0xe8b(%rip),%rsi
mov    %rax,%rdi
call   1070 <strstr@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
je     120f <fm_team_info+0xbf>
mov    %rax,%rbp
add    $0xa,%rbp
mov    %rbp,%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     120f <fm_team_info+0xbf>
mov    %rax,%rbx
sub    %rbp,%rbx
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1060 <memcpy@plt>
movb   $0x0,0x1(%rbx,%r12,1)
lea    0xe4a(%rip),%rsi
mov    %r13,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     120f <fm_team_info+0xbf>
mov    %rax,%rbp
add    $0x9,%rbp
mov    %rbp,%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     120f <fm_team_info+0xbf>
mov    %rax,%r12
sub    %rbp,%r12
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1060 <memcpy@plt>
movb   $0x0,0x1(%r12,%r14,1)
xor    %r15d,%r15d
mov    %r13,%rdi
call   1030 <free@plt>
jmp    121f <fm_team_info+0xcf>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"probe.team\00"
@.str.1 = [11 x i8] c"team_name:\00"
@.str.2 = [10 x i8] c"pin_code:\00"
define i32 @fm_team_info(i8* %0, i8* %1) {
%3 = tail call i8* @fm_read(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %37, label %5
5: ; preds = %2
%6 = tail call i8* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %34, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %6, i64 10
%10 = tail call i8* @strchr(i8* %9, i8 signext 59)
%11 = icmp eq i8* %10, null
br i1 %11, label %34, label %12
12: ; preds = %8
%13 = ptrtoint i8* %10 to i64
%14 = ptrtoint i8* %9 to i64
%15 = sub i64 %13, %14
%16 = trunc i64 %15 to i32
%17 = tail call i32 @memcpy(i8* %0, i8* %9, i32 %16)
%18 = add nsw i64 %15, 1
%19 = getelementptr inbounds i8, i8* %0, i64 %18
store i8 0, i8* %19
%20 = tail call i8* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %34, label %22
22: ; preds = %12
%23 = getelementptr inbounds i8, i8* %20, i64 9
%24 = tail call i8* @strchr(i8* %23, i8 signext 59)
%25 = icmp eq i8* %24, null
br i1 %25, label %34, label %26
26: ; preds = %22
%27 = ptrtoint i8* %24 to i64
%28 = ptrtoint i8* %23 to i64
%29 = sub i64 %27, %28
%30 = trunc i64 %29 to i32
%31 = tail call i32 @memcpy(i8* %1, i8* %23, i32 %30)
%32 = add nsw i64 %29, 1
%33 = getelementptr inbounds i8, i8* %1, i64 %32
store i8 0, i8* %33
br label %34
34: ; preds = %22, %12, %8, %5, %26
%35 = phi i32 [ 0, %26 ], [ -1, %5 ], [ -1, %8 ], [ -1, %12 ], [ -1, %22 ]
%36 = tail call i32 @free(i8* %3)
br label %37
37: ; preds = %34, %2
%38 = phi i32 [ -1, %2 ], [ %35, %34 ]
ret i32 %38
}