#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 O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int open(char *, int, ...);
int /*<<< orphan*/ read(int, int *, int);
int /*<<< orphan*/ write(int, ...);
int main() {
  int fd1, fd2;
  int macbyte;
  int i;
  fd1 = open("/data/misc/wifi/macAddress", O_RDONLY);
  fd2 = open("/data/misc/wifi/config", O_WRONLY | O_CREAT | O_TRUNC,
             S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  write(fd2, "mpc=1\n", 6);
  write(fd2, "roam_off=0\n", 11);
  write(fd2, "roam_scan_period=10\n", 20);
  write(fd2, "roam_delta=20\n", 14);
  write(fd2, "roam_trigger=-70\n", 17);
  write(fd2, "PM=2\n", 5);
  write(fd2, "cur_etheraddr=", 14);
  for (i = 0; i < 12; i++) {
    lseek(fd1, i, SEEK_SET);
    lseek(fd2, 0, SEEK_END);
    read(fd1, &macbyte, 1);
    if (i > 1 && !(i % 2))
      write(fd2, ":", 1);
    write(fd2, &macbyte, 1);
  }
  write(fd2, "\n", 1);
  close(fd1);
  close(fd2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
mov    0x2e6f(%rip),%rax
or     (%rax),%esi
mov    0x2e5e(%rip),%rax
or     (%rax),%esi
mov    0x2e05(%rip),%rax
mov    (%rax),%edx
mov    0x2e24(%rip),%rax
or     (%rax),%edx
mov    0x2e03(%rip),%rax
or     (%rax),%edx
mov    0x2df2(%rip),%rax
or     (%rax),%edx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    0xe5f(%rip),%rsi
mov    $0x6,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
lea    0xe50(%rip),%rsi
mov    $0xb,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
lea    0xe46(%rip),%rsi
mov    $0x14,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
lea    0xe45(%rip),%rsi
mov    $0xe,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
lea    0xe3e(%rip),%rsi
mov    $0x11,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
lea    0xe3a(%rip),%rsi
mov    $0x5,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
lea    0xe2a(%rip),%rsi
mov    $0xe,%edx
mov    $0x0,%al
call   1030 <write@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jge    1301 <main+0x1b1>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    0x2d37(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    -0xc(%rbp),%edi
mov    0x2d46(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
cmpl   $0x1,-0x14(%rbp)
jle    12e0 <main+0x190>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12e0 <main+0x190>
mov    -0xc(%rbp),%edi
lea    0xdbc(%rip),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    126a <main+0x11a>
mov    -0xc(%rbp),%edi
lea    0xd4d(%rip),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1070 <open@plt>
mov    0x2e17(%rip),%rcx
mov    0x2e78(%rip),%rdx
mov    (%rdx),%esi
or     (%rcx),%esi
mov    0x2e65(%rip),%rcx
or     (%rcx),%esi
mov    0x2e0c(%rip),%rcx
mov    0x2e2d(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2e0a(%rip),%rcx
or     (%rcx),%edx
mov    %eax,%r14d
mov    0x2df6(%rip),%rax
or     (%rax),%edx
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1070 <open@plt>
mov    %eax,%ebp
lea    0xe67(%rip),%rsi
mov    %eax,%edi
mov    $0x6,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xe59(%rip),%rsi
mov    %ebp,%edi
mov    $0xb,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xe50(%rip),%rsi
mov    %ebp,%edi
mov    $0x14,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xe50(%rip),%rsi
mov    %ebp,%edi
mov    $0xe,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xe4a(%rip),%rsi
mov    %ebp,%edi
mov    $0x11,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xe47(%rip),%rsi
mov    %ebp,%edi
mov    $0x5,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xe38(%rip),%rsi
mov    %ebp,%edi
mov    $0xe,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    0x2d5a(%rip),%r13
mov    0x2d73(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ebx,%ebx
jmp    1289 <main+0x139>
xchg   %ax,%ax
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
add    $0x1,%ebx
cmp    $0xc,%ebx
je     12d6 <main+0x186>
mov    0x0(%r13),%edx
mov    %r14d,%edi
mov    %ebx,%esi
call   1040 <lseek@plt>
mov    (%r15),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %r14d,%edi
mov    %r12,%rsi
mov    $0x1,%edx
call   1060 <read@plt>
cmp    $0x2,%ebx
jb     1270 <main+0x120>
mov    %ebx,%eax
and    $0x1,%eax
jne    1270 <main+0x120>
mov    %ebp,%edi
lea    0xdc8(%rip),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
jmp    1270 <main+0x120>
lea    0xd7b(%rip),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    %r14d,%edi
call   1050 <close@plt>
mov    %ebp,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"/data/misc/wifi/macAddress\00"
@O_RDONLY = global i32 0
@.str.1 = [23 x i8] c"/data/misc/wifi/config\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str.2 = [7 x i8] c"mpc=1\0A\00"
@.str.3 = [12 x i8] c"roam_off=0\0A\00"
@.str.4 = [21 x i8] c"roam_scan_period=10\0A\00"
@.str.5 = [15 x i8] c"roam_delta=20\0A\00"
@.str.6 = [18 x i8] c"roam_trigger=-70\0A\00"
@.str.7 = [6 x i8] c"PM=2\0A\00"
@.str.8 = [15 x i8] c"cur_etheraddr=\00"
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
@.str.9 = [2 x i8] c":\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @O_RDONLY
%7 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %2
%8 = load i32, i32* @O_WRONLY
%9 = load i32, i32* @O_CREAT
%10 = or i32 %8, %9
%11 = load i32, i32* @O_TRUNC
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IRUSR
%14 = load i32, i32* @S_IWUSR
%15 = or i32 %13, %14
%16 = load i32, i32* @S_IRGRP
%17 = or i32 %15, %16
%18 = load i32, i32* @S_IROTH
%19 = or i32 %17, %18
%20 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %19)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = call i32 (i32, ...) @write(i32 %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%23 = load i32, i32* %3
%24 = call i32 (i32, ...) @write(i32 %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 11)
%25 = load i32, i32* %3
%26 = call i32 (i32, ...) @write(i32 %25, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 20)
%27 = load i32, i32* %3
%28 = call i32 (i32, ...) @write(i32 %27, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 14)
%29 = load i32, i32* %3
%30 = call i32 (i32, ...) @write(i32 %29, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 17)
%31 = load i32, i32* %3
%32 = call i32 (i32, ...) @write(i32 %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%33 = load i32, i32* %3
%34 = call i32 (i32, ...) @write(i32 %33, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 14)
store i32 0, i32* %5
br label %35
35: ; preds = %60, %0
%36 = load i32, i32* %5
%37 = icmp slt i32 %36, 12
br i1 %37, label %38, label %63
38: ; preds = %35
%39 = load i32, i32* %2
%40 = load i32, i32* %5
%41 = load i32, i32* @SEEK_SET
%42 = call i32 @lseek(i32 %39, i32 %40, i32 %41)
%43 = load i32, i32* %3
%44 = load i32, i32* @SEEK_END
%45 = call i32 @lseek(i32 %43, i32 0, i32 %44)
%46 = load i32, i32* %2
%47 = call i32 @read(i32 %46, i32* %4, i32 1)
%48 = load i32, i32* %5
%49 = icmp sgt i32 %48, 1
br i1 %49, label %50, label %57
50: ; preds = %38
%51 = load i32, i32* %5
%52 = srem i32 %51, 2
%53 = icmp ne i32 %52, 0
br i1 %53, label %57, label %54
54: ; preds = %50
%55 = load i32, i32* %3
%56 = call i32 (i32, ...) @write(i32 %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
br label %57
57: ; preds = %54, %50, %38
%58 = load i32, i32* %3
%59 = call i32 (i32, ...) @write(i32 %58, i32* %4, i32 1)
br label %60
60: ; preds = %57
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 1
store i32 %62, i32* %5
br label %35
63: ; preds = %35
%64 = load i32, i32* %3
%65 = call i32 (i32, ...) @write(i32 %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 1)
%66 = load i32, i32* %2
%67 = call i32 @close(i32 %66)
%68 = load i32, i32* %3
%69 = call i32 @close(i32 %68)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"/data/misc/wifi/macAddress\00"
@O_RDONLY = global i32 0
@.str.1 = [23 x i8] c"/data/misc/wifi/config\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str.2 = [7 x i8] c"mpc=1\0A\00"
@.str.3 = [12 x i8] c"roam_off=0\0A\00"
@.str.4 = [21 x i8] c"roam_scan_period=10\0A\00"
@.str.5 = [15 x i8] c"roam_delta=20\0A\00"
@.str.6 = [18 x i8] c"roam_trigger=-70\0A\00"
@.str.7 = [6 x i8] c"PM=2\0A\00"
@.str.8 = [15 x i8] c"cur_etheraddr=\00"
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
@.str.9 = [2 x i8] c":\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @O_WRONLY
%6 = load i32, i32* @O_CREAT
%7 = or i32 %6, %5
%8 = load i32, i32* @O_TRUNC
%9 = or i32 %7, %8
%10 = load i32, i32* @S_IRUSR
%11 = load i32, i32* @S_IWUSR
%12 = or i32 %11, %10
%13 = load i32, i32* @S_IRGRP
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IROTH
%16 = or i32 %14, %15
%17 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %16)
%18 = tail call i32 (i32, ...) @write(i32 %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%19 = tail call i32 (i32, ...) @write(i32 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 11)
%20 = tail call i32 (i32, ...) @write(i32 %17, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 20)
%21 = tail call i32 (i32, ...) @write(i32 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 14)
%22 = tail call i32 (i32, ...) @write(i32 %17, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 17)
%23 = tail call i32 (i32, ...) @write(i32 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%24 = tail call i32 (i32, ...) @write(i32 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 14)
br label %25
25: ; preds = %0, %38
%26 = phi i32 [ 0, %0 ], [ %40, %38 ]
%27 = load i32, i32* @SEEK_SET
%28 = call i32 @lseek(i32 %4, i32 %26, i32 %27)
%29 = load i32, i32* @SEEK_END
%30 = call i32 @lseek(i32 %17, i32 0, i32 %29)
%31 = call i32 @read(i32 %4, i32* %1, i32 1)
%32 = icmp ugt i32 %26, 1
%33 = and i32 %26, 1
%34 = icmp eq i32 %33, 0
%35 = and i1 %32, %34
br i1 %35, label %36, label %38
36: ; preds = %25
%37 = call i32 (i32, ...) @write(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
br label %38
38: ; preds = %36, %25
%39 = call i32 (i32, ...) @write(i32 %17, i32* %1, i32 1)
%40 = add nuw nsw i32 %26, 1
%41 = icmp eq i32 %40, 12
br i1 %41, label %42, label %25
42: ; preds = %38
%43 = call i32 (i32, ...) @write(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 1)
%44 = call i32 @close(i32 %4)
%45 = call i32 @close(i32 %17)
ret i32 0
}