#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 timeval {
  int member_0;
  int /*<<< orphan*/ member_1;
};
typedef int /*<<< orphan*/ message;
typedef int /*<<< orphan*/ buff;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVTIMEO;
int /*<<< orphan*/ close_tcp_client(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int open_tcp_client(char *, int);
int /*<<< orphan*/ printf(char *);
scalar_t__ recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              char *, int);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *, char *);
char *str_change(char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
char *strstr(char *, char *);
char *strtok(char *, char *);
void main(void) {
  char *host = "standards.ieee.org";
  char *name = "/tmp/mac_access.h";
  int port = 80, sockfd;
  char buff[2048], message[2048], mac[16];
  char ch_1[8], ch_2[8], ch_3[8];
  char *str, *delime = "<hr><p><pre>";
  FILE *fp, *file;
  if ((sockfd = open_tcp_client(host, port)) < 0) {
    printf("Error opening socket!\n");
    exit(1);
  }
  memset(message, 0, sizeof(message));
  memset(buff, 0, sizeof(buff));
  sprintf(message, "GET /cgi-bin/ouisearch?1%20Infinite%20Loop HTTP/1.1\r\n");
  strcat(message, "Host:standards.ieee.org\r\n");
  strcat(message, "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; "
                  "rv:29.0) Gecko/20100101 Firefox/29.0\r\n");
  strcat(message,
         "Accept: "
         "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n");
  strcat(message, "Accept-Language: zh-tw,zh;q=0.8,en-us;q=0.5,en;q=0.3\r\n");
  strcat(message, "Connection: keep-alive\r\n");
  strcat(message, "Cache-Control: max-age=0\r\n");
  strcat(message, "\r\n\r\n");
  if (send(sockfd, message, strlen(message), 0) == -1) {
    printf("Error in send\n");
    exit(1);
  }
  struct timeval timeout = {1, 0};
  setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,
             sizeof(struct timeval));
  fp = fopen("/tmp/123.tmp", "w");
  for (; recv(sockfd, buff, sizeof(buff), 0);) {
    fprintf(fp, "%s", buff);
    memset(buff, 0, sizeof(buff));
  }
  fclose(fp);
  close_tcp_client(sockfd);
  fp = fopen("/tmp/123.tmp", "r");
  file = fopen(name, "w");
  fprintf(file, "char *mac_access[] = {\n");
  while (fgets(buff, sizeof(buff), fp) != NULL) {
    str = strtok(buff, delime);
    while (str != NULL) {
      if (strstr(str, "-") - str == 4) {
        sscanf(str, "  %[^-]-%[^-]-%s", ch_1, ch_2, ch_3);
        if ((strlen(ch_1) + strlen(ch_2) + strlen(ch_3)) == 6)
          fprintf(file, "\t\"%s:%s:%s\",\n", str_change(ch_1), str_change(ch_2),
                  str_change(ch_3));
      }
      str = strtok(NULL, delime);
    }
  }
  fprintf(file, "};");
  fclose(file);
  fclose(fp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10a0,%rsp
lea    0xdbe(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xdc6(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x50,-0x14(%rbp)
lea    0xdc6(%rip),%rax
mov    %rax,-0x1058(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10e0 <open_tcp_client@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1294 <main+0x64>
lea    0xdad(%rip),%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
lea    -0x1020(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   10a0 <memset@plt>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   10a0 <memset@plt>
lea    -0x1020(%rbp),%rdi
lea    0xd81(%rip),%rsi
call   1130 <sprintf@plt>
lea    -0x1020(%rbp),%rdi
lea    0xda4(%rip),%rsi
call   1120 <strcat@plt>
lea    -0x1020(%rbp),%rdi
lea    0xdab(%rip),%rsi
call   1120 <strcat@plt>
lea    -0x1020(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   1120 <strcat@plt>
lea    -0x1020(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1120 <strcat@plt>
lea    -0x1020(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1120 <strcat@plt>
lea    -0x1020(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1120 <strcat@plt>
lea    -0x1020(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1120 <strcat@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x107c(%rbp)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1078(%rbp)
lea    -0x1020(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x107c(%rbp),%edi
mov    -0x1078(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
jne    13aa <main+0x17a>
lea    0xe13(%rip),%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
mov    0xe5b(%rip),%rax
mov    %rax,-0x1070(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2c26(%rip),%rax
mov    (%rax),%esi
mov    0x2c0d(%rip),%rax
mov    (%rax),%edx
lea    -0x1070(%rbp),%rcx
mov    $0x8,%r8d
call   1040 <setsockopt@plt>
lea    0xdd7(%rip),%rdi
lea    0xddd(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x1060(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
je     144d <main+0x21d>
mov    -0x1060(%rbp),%rdi
lea    -0x820(%rbp),%rdx
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   10a0 <memset@plt>
jmp    13f9 <main+0x1c9>
mov    -0x1060(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%edi
call   1090 <close_tcp_client@plt>
lea    0xd55(%rip),%rdi
lea    0xd5d(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x1060(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd44(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x1068(%rbp)
mov    -0x1068(%rbp),%rdi
lea    0xd2e(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x1060(%rbp),%rdx
mov    $0x800,%esi
call   10c0 <fgets@plt>
cmp    $0x0,%rax
je     1619 <main+0x3e9>
lea    -0x820(%rbp),%rdi
mov    -0x1058(%rbp),%rsi
call   1110 <strtok@plt>
mov    %rax,-0x1050(%rbp)
cmpq   $0x0,-0x1050(%rbp)
je     1614 <main+0x3e4>
mov    -0x1050(%rbp),%rdi
lea    0xce7(%rip),%rsi
call   1150 <strstr@plt>
mov    -0x1050(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x4,%rax
jne    15f8 <main+0x3c8>
mov    -0x1050(%rbp),%rdi
lea    -0x1038(%rbp),%rdx
lea    -0x1040(%rbp),%rcx
lea    -0x1048(%rbp),%r8
lea    0xcad(%rip),%rsi
call   10f0 <sscanf@plt>
lea    -0x1038(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x1084(%rbp)
lea    -0x1040(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x1084(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1080(%rbp)
lea    -0x1048(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x1080(%rbp),%eax
add    %ecx,%eax
cmp    $0x6,%eax
jne    15f3 <main+0x3c3>
mov    -0x1068(%rbp),%rax
mov    %rax,-0x10a0(%rbp)
lea    -0x1038(%rbp),%rdi
call   10b0 <str_change@plt>
mov    %rax,-0x1098(%rbp)
lea    -0x1040(%rbp),%rdi
call   10b0 <str_change@plt>
mov    %rax,-0x1090(%rbp)
lea    -0x1048(%rbp),%rdi
call   10b0 <str_change@plt>
mov    -0x10a0(%rbp),%rdi
mov    -0x1098(%rbp),%rdx
mov    -0x1090(%rbp),%rcx
mov    %rax,%r8
lea    0xc0d(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
jmp    15f8 <main+0x3c8>
mov    -0x1058(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1110 <strtok@plt>
mov    %rax,-0x1050(%rbp)
jmp    14e3 <main+0x2b3>
jmp    14a7 <main+0x277>
mov    -0x1068(%rbp),%rdi
lea    0xbe0(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x1068(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x1060(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x10a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1038,%rsp
lea    0xd98(%rip),%rdi
mov    $0x50,%esi
call   1100 <open_tcp_client@plt>
test   %eax,%eax
js     1589 <main+0x339>
mov    %eax,%r14d
lea    0x830(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   10c0 <memset@plt>
lea    0x30(%rsp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   10c0 <memset@plt>
lea    0xd86(%rip),%rsi
mov    %rbp,%rdi
call   1150 <sprintf@plt>
lea    0xdad(%rip),%rsi
mov    %rbp,%rdi
call   1140 <strcat@plt>
lea    0xdb8(%rip),%rsi
mov    %rbp,%rdi
call   1140 <strcat@plt>
lea    0xe04(%rip),%rsi
mov    %rbp,%rdi
call   1140 <strcat@plt>
lea    0xe3f(%rip),%rsi
mov    %rbp,%rdi
call   1140 <strcat@plt>
lea    0xe67(%rip),%rsi
mov    %rbp,%rdi
call   1140 <strcat@plt>
lea    0xe71(%rip),%rsi
mov    %rbp,%rdi
call   1140 <strcat@plt>
lea    0xe7d(%rip),%rsi
mov    %rbp,%rdi
call   1140 <strcat@plt>
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0xffffffff,%eax
je     1592 <main+0x342>
movq   $0x1,0x10(%rsp)
mov    0x2c9b(%rip),%rax
mov    (%rax),%esi
mov    0x2c82(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rcx
mov    %r14d,%edi
mov    $0x8,%r8d
call   1050 <setsockopt@plt>
lea    0xe25(%rip),%rdi
lea    0xe2b(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,%rbp
lea    0x30(%rsp),%rsi
mov    %r14d,%edi
mov    $0x800,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
je     13d1 <main+0x181>
lea    0x30(%rsp),%rbx
nop
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10b0 <fputs@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   10c0 <memset@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x800,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jne    13a0 <main+0x150>
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    %r14d,%edi
call   10a0 <close_tcp_client@plt>
lea    0xdaf(%rip),%rdi
lea    0xdb7(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,%rbx
lea    0xc15(%rip),%rdi
lea    0xd9f(%rip),%rsi
call   1120 <fopen@plt>
lea    0xd97(%rip),%rdi
mov    $0x17,%esi
mov    $0x1,%edx
mov    %rax,0x8(%rsp)
mov    %rax,%rcx
call   1170 <fwrite@plt>
lea    0x30(%rsp),%rdi
mov    $0x800,%esi
mov    %rbx,(%rsp)
mov    %rbx,%rdx
call   10e0 <fgets@plt>
test   %rax,%rax
je     1548 <main+0x2f8>
lea    0x30(%rsp),%rbx
lea    0x28(%rsp),%r13
lea    0x20(%rsp),%r14
lea    0x18(%rsp),%r12
jmp    147f <main+0x22f>
nopl   (%rax)
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x800,%esi
mov    (%rsp),%rdx
call   10e0 <fgets@plt>
test   %rax,%rax
je     1548 <main+0x2f8>
mov    %rbx,%rdi
lea    0xb9c(%rip),%rsi
call   1130 <strtok@plt>
test   %rax,%rax
je     1460 <main+0x210>
mov    %rax,%r15
jmp    14b6 <main+0x266>
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
lea    0xb7c(%rip),%rsi
call   1130 <strtok@plt>
mov    %rax,%r15
test   %rax,%rax
je     1460 <main+0x210>
mov    %r15,%rdi
mov    $0x2d,%esi
call   1090 <strchr@plt>
sub    %r15,%rax
cmp    $0x4,%rax
jne    14a0 <main+0x250>
mov    %r15,%rdi
lea    0xcea(%rip),%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %r12,%r8
call   1110 <sscanf@plt>
mov    %r13,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r12,%rdi
call   1070 <strlen@plt>
add    %ebp,%eax
cmp    $0x6,%eax
jne    14a0 <main+0x250>
mov    %r13,%rdi
call   10d0 <str_change@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   10d0 <str_change@plt>
mov    %rax,%rbp
mov    %r12,%rdi
call   10d0 <str_change@plt>
mov    0x8(%rsp),%rdi
lea    0xc9e(%rip),%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   10f0 <fprintf@plt>
jmp    14a0 <main+0x250>
lea    0xc90(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    0x8(%rsp),%rbx
mov    %rbx,%rcx
call   1170 <fwrite@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    (%rsp),%rdi
call   1060 <fclose@plt>
add    $0x1038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc60(%rip),%rdi
jmp    1599 <main+0x349>
lea    0xc49(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1160 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [19 x i8] c"standards.ieee.org\00"
@.str.1 = [18 x i8] c"/tmp/mac_access.h\00"
@.str.2 = [13 x i8] c"<hr><p><pre>\00"
@.str.3 = [23 x i8] c"Error opening socket!\0A\00"
@.str.4 = [54 x i8] c"GET /cgi-bin/ouisearch?1%20Infinite%20Loop HTTP/1.1\0D\0A\00"
@.str.5 = [26 x i8] c"Host:standards.ieee.org\0D\0A\00"
@.str.6 = [91 x i8] c"User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0\0D\0A\00"
@.str.7 = [74 x i8] c"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\0D\0A\00"
@.str.8 = [55 x i8] c"Accept-Language: zh-tw,zh;q=0.8,en-us;q=0.5,en;q=0.3\0D\0A\00"
@.str.9 = [25 x i8] c"Connection: keep-alive\0D\0A\00"
@.str.10 = [27 x i8] c"Cache-Control: max-age=0\0D\0A\00"
@.str.11 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.12 = [15 x i8] c"Error in send\0A\00"
@__const.main.timeout = %struct.timeval { i32 1, i32 0 }
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@.str.13 = [13 x i8] c"/tmp/123.tmp\00"
@.str.14 = [2 x i8] c"w\00"
@.str.15 = [3 x i8] c"%s\00"
@.str.16 = [2 x i8] c"r\00"
@.str.17 = [24 x i8] c"char *mac_access[] = {\0A\00"
@.str.18 = [2 x i8] c"-\00"
@.str.19 = [17 x i8] c" %[^-]-%[^-]-%s\00"
@.str.20 = [14 x i8] c"\09\22%s:%s:%s\22,\0A\00"
@.str.21 = [3 x i8] c"};\00"
define void @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2048 x i8]
%6 = alloca [2048 x i8]
%7 = alloca [16 x i8]
%8 = alloca [8 x i8]
%9 = alloca [8 x i8]
%10 = alloca [8 x i8]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca %struct.timeval
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i32 80, i32* %3
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8** %12
%16 = load i8*, i8** %1
%17 = load i32, i32* %3
%18 = call i32 @open_tcp_client(i8* %16, i32 %17)
store i32 %18, i32* %4
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %0
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %0
%24 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%25 = call i32 @memset(i8* %24, i32 0, i32 2048)
%26 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%27 = call i32 @memset(i8* %26, i32 0, i32 2048)
%28 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%29 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%30 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%32 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.6, i64 0, i64 0))
%34 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.7, i64 0, i64 0))
%36 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0))
%38 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%39 = call i32 @strcat(i8* %38, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%40 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%42 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%43 = call i32 @strcat(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%44 = load i32, i32* %4
%45 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%46 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
%48 = call i32 @send(i32 %44, i8* %45, i32 %47, i32 0)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %53
50: ; preds = %23
%51 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %23
%54 = bitcast %struct.timeval* %15 to i8*
%55 = load i32, i32* %4
%56 = load i32, i32* @SOL_SOCKET
%57 = load i32, i32* @SO_RCVTIMEO
%58 = bitcast %struct.timeval* %15 to i8*
%59 = call i32 @setsockopt(i32 %55, i32 %56, i32 %57, i8* %58, i32 8)
%60 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i32* %60, i32** %13
br label %61
61: ; preds = %66, %53
%62 = load i32, i32* %4
%63 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%64 = call i64 @recv(i32 %62, i8* %63, i32 2048, i32 0)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %72
66: ; preds = %61
%67 = load i32*, i32** %13
%68 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8* %68)
%70 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%71 = call i32 @memset(i8* %70, i32 0, i32 2048)
br label %61
72: ; preds = %61
%73 = load i32*, i32** %13
%74 = call i32 @fclose(i32* %73)
%75 = load i32, i32* %4
%76 = call i32 @close_tcp_client(i32 %75)
%77 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
store i32* %77, i32** %13
%78 = load i8*, i8** %2
%79 = call i32* @fopen(i8* %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i32* %79, i32** %14
%80 = load i32*, i32** %14
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.17, i64 0, i64 0))
br label %82
82: ; preds = %130, %72
%83 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%84 = load i32*, i32** %13
%85 = call i32* @fgets(i8* %83, i32 2048, i32* %84)
%86 = icmp ne i32* %85, null
br i1 %86, label %87, label %131
87: ; preds = %82
%88 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%89 = load i8*, i8** %12
%90 = call i8* @strtok(i8* %88, i8* %89)
store i8* %90, i8** %11
br label %91
91: ; preds = %127, %87
%92 = load i8*, i8** %11
%93 = icmp ne i8* %92, null
br i1 %93, label %94, label %130
94: ; preds = %91
%95 = load i8*, i8** %11
%96 = call i8* @strstr(i8* %95, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%97 = load i8*, i8** %11
%98 = ptrtoint i8* %96 to i64
%99 = ptrtoint i8* %97 to i64
%100 = sub i64 %98, %99
%101 = icmp eq i64 %100, 4
br i1 %101, label %102, label %127
102: ; preds = %94
%103 = load i8*, i8** %11
%104 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%105 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%106 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%107 = call i32 @sscanf(i8* %103, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i64 0, i64 0), i8* %104, i8* %105, i8* %106)
%108 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%109 = call i32 @strlen(i8* %108)
%110 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%111 = call i32 @strlen(i8* %110)
%112 = add nsw i32 %109, %111
%113 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%114 = call i32 @strlen(i8* %113)
%115 = add nsw i32 %112, %114
%116 = icmp eq i32 %115, 6
br i1 %116, label %117, label %126
117: ; preds = %102
%118 = load i32*, i32** %14
%119 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%120 = call i8* @str_change(i8* %119)
%121 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%122 = call i8* @str_change(i8* %121)
%123 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%124 = call i8* @str_change(i8* %123)
%125 = call i32 (i32*, i8*, ...) @fprintf(i32* %118, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.20, i64 0, i64 0), i8* %120, i8* %122, i8* %124)
br label %126
126: ; preds = %117, %102
br label %127
127: ; preds = %126, %94
%128 = load i8*, i8** %12
%129 = call i8* @strtok(i8* null, i8* %128)
store i8* %129, i8** %11
br label %91
130: ; preds = %91
br label %82
131: ; preds = %82
%132 = load i32*, i32** %14
%133 = call i32 (i32*, i8*, ...) @fprintf(i32* %132, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0))
%134 = load i32*, i32** %14
%135 = call i32 @fclose(i32* %134)
%136 = load i32*, i32** %13
%137 = call i32 @fclose(i32* %136)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"standards.ieee.org\00"
@.str.1 = [18 x i8] c"/tmp/mac_access.h\00"
@.str.2 = [13 x i8] c"<hr><p><pre>\00"
@.str.4 = [54 x i8] c"GET /cgi-bin/ouisearch?1%20Infinite%20Loop HTTP/1.1\0D\0A\00"
@.str.5 = [26 x i8] c"Host:standards.ieee.org\0D\0A\00"
@.str.6 = [91 x i8] c"User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0\0D\0A\00"
@.str.7 = [74 x i8] c"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\0D\0A\00"
@.str.8 = [55 x i8] c"Accept-Language: zh-tw,zh;q=0.8,en-us;q=0.5,en;q=0.3\0D\0A\00"
@.str.9 = [25 x i8] c"Connection: keep-alive\0D\0A\00"
@.str.10 = [27 x i8] c"Cache-Control: max-age=0\0D\0A\00"
@.str.11 = [5 x i8] c"\0D\0A\0D\0A\00"
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@.str.13 = [13 x i8] c"/tmp/123.tmp\00"
@.str.14 = [2 x i8] c"w\00"
@.str.16 = [2 x i8] c"r\00"
@.str.17 = [24 x i8] c"char *mac_access[] = {\0A\00"
@.str.19 = [17 x i8] c" %[^-]-%[^-]-%s\00"
@.str.20 = [14 x i8] c"\09\22%s:%s:%s\22,\0A\00"
@.str.21 = [3 x i8] c"};\00"
@str = [14 x i8] c"Error in send\00"
@str.22 = [22 x i8] c"Error opening socket!\00"
define void @main() {
%1 = alloca [2048 x i8]
%2 = alloca [2048 x i8]
%3 = alloca [8 x i8]
%4 = alloca [8 x i8]
%5 = alloca [8 x i8]
%6 = alloca i64
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%12 = tail call i32 @open_tcp_client(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 80)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.22, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %0
%18 = call i32 @memset(i8* %8, i32 0, i32 2048)
%19 = call i32 @memset(i8* %7, i32 0, i32 2048)
%20 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.7, i64 0, i64 0))
%24 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0))
%25 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%26 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%27 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%28 = call i32 @strlen(i8* %8)
%29 = call i32 @send(i32 %12, i8* %8, i32 %28, i32 0)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %34
31: ; preds = %17
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %17
%35 = bitcast i64* %6 to i8*
store i64 1, i64* %6
%36 = load i32, i32* @SOL_SOCKET
%37 = load i32, i32* @SO_RCVTIMEO
%38 = call i32 @setsockopt(i32 %12, i32 %36, i32 %37, i8* %35, i32 8)
%39 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%40 = call i64 @recv(i32 %12, i8* %7, i32 2048, i32 0)
%41 = icmp eq i64 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %34, %42
%43 = call i32 @fputs(i8* %7, i32* %39)
%44 = call i32 @memset(i8* %7, i32 0, i32 2048)
%45 = call i64 @recv(i32 %12, i8* %7, i32 2048, i32 0)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %42
47: ; preds = %42, %34
%48 = call i32 @fclose(i32* %39)
%49 = call i32 @close_tcp_client(i32 %12)
%50 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%51 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%52 = call i64 @fwrite(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.17, i64 0, i64 0), i64 23, i64 1, i32* %51)
%53 = call i32* @fgets(i8* %7, i32 2048, i32* %50)
%54 = icmp eq i32* %53, null
br i1 %54, label %84, label %58
55: ; preds = %81, %58
%56 = call i32* @fgets(i8* %7, i32 2048, i32* %50)
%57 = icmp eq i32* %56, null
br i1 %57, label %84, label %58
58: ; preds = %47, %55
%59 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%60 = icmp eq i8* %59, null
br i1 %60, label %55, label %61
61: ; preds = %58, %81
%62 = phi i8* [ %82, %81 ], [ %59, %58 ]
%63 = call i8* @strchr(i8* %62, i32 45)
%64 = ptrtoint i8* %63 to i64
%65 = ptrtoint i8* %62 to i64
%66 = sub i64 %64, %65
%67 = icmp eq i64 %66, 4
br i1 %67, label %68, label %81
68: ; preds = %61
%69 = call i32 @sscanf(i8* %62, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i64 0, i64 0), i8* %9, i8* %10, i8* %11)
%70 = call i32 @strlen(i8* %9)
%71 = call i32 @strlen(i8* %10)
%72 = add nsw i32 %71, %70
%73 = call i32 @strlen(i8* %11)
%74 = add nsw i32 %72, %73
%75 = icmp eq i32 %74, 6
br i1 %75, label %76, label %81
76: ; preds = %68
%77 = call i8* @str_change(i8* %9)
%78 = call i8* @str_change(i8* %10)
%79 = call i8* @str_change(i8* %11)
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.20, i64 0, i64 0), i8* %77, i8* %78, i8* %79)
br label %81
81: ; preds = %68, %76, %61
%82 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%83 = icmp eq i8* %82, null
br i1 %83, label %55, label %61
84: ; preds = %55, %47
%85 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i64 2, i64 1, i32* %51)
%86 = call i32 @fclose(i32* %51)
%87 = call i32 @fclose(i32* %50)
ret void
}